JPEG Compression — Devil or Angel?
posted April 23, 2006
You only have to fool with digital photography a short time before someone says something like, “Try to avoid JPG, it degrades your images, and each time you save the image it becomes worse and worse.” And they may add, “You need to buy a camera that supports RAW images and use that exclusively.” In this article I will try to shed some light on the pros and cons of using JPEG normally call JPG. JPEG is simply a file compression method. To identify files compressed using the JPG method they’re given the extension jpg (The letters after the dot at the end of a filename are called the extension.). Digital images tend to be large and so use a lot of storage space (and web resources). To combat this, ways of compressing image data have been devised. By far the most widely used compression method is JPEG. [GIF and PNG are also compression methods. They are best suited to graphical images that only have discrete colors.]
The JPEG method of image storage can achieve a remarkable amount of compression (reduction in file size). It can reduce the file size by as much as a factor of 20 and still have a reasonably good image. But, it’s not a free lunch. To achieve its remarkable compression it throws away small amounts of the original image data, and the greater the compression the more of the image gets thrown away/lost. For this reason it’s called a “lossy” compression method. This is why people are warned against using JPEG.
I’ll start by saying if it’s about as easy for you to record/store your images in one of the lossless format such as TIFF or RAW, by all means do so. But, it’s impractical to use large uncompressed images on the web and they bog down email, particularly for those who use dialup. And, let’s say you can take 100 of the highest quality (least compression) JPEG pictures on your camera’s memory card. You’ll likely only be able to take about 15 pictures using TIFF. Also, you may be able to shoot 6-10 pictures in rapid succession using JPEG, where you’ll have to wait 10 to 20 seconds between shots for the camera to finish recording each TIFF picture.
You’ll hear people talk about JPG artifacts. They may say saving an image over and over in JPG is like passing it through a copy machine repeatedly — the image degrades every time you save it. I hope to to shed some light on these things.
Disclaimer — I am not expert in these areas. For example, I don’t know how the JPEG compression algorithm works. I will simply show you some images I have fooled around with in PhotoShop, and tell you what I think they show and let you judge for yourself.
For these illustrations/comparisons I want you to see the pictures side-by-side. In order to do this I will sometimes use the same pictures more than once. When I use the same caption name, it is the same picture. The original picture used in these illustrations is at the top of the page. I’ve magnified the demonstration images to make differences more apparent, so the image named “Original X3” is the original picture magnified three times.
This first illustration is a comparison of the original (magnified 3 times) with a JPEG of the same image using moderately aggressive compression (50 in PhotoShop’s Save For Web). You may not notice much difference at first, but as you study the image on the right you will begin to see areas where it is disintegrating. Look carefully near the outer edges of the upper petals. Also, look on the petals around the yellow “eyes” Also, at the small petal at the 4 o’clock position. This is JPG artifact.
|Original X3||1st generation JPG of original|
Below, when you compare the original with the same JPG compressed image in actual size (not magnified) you don’t see the artifact, but of course, you and I know it’s there, so our obsessive selves can brood about it.
|Original||1st Gen JPG|
Now about the copy machine analogy. The picture on the left below is the same as the one above on the right. The picture below on the right is this very same picture saved ten more times using the same compression (50 in PhotoShop’s Save For Web). The first generation of compression left obvious JPG artifacts, but many subsequent saves at the same compression level caused no further degradation. And, I’m not even a guest star on Mythbusters. The answer is, as long as you use an amount of compression less than or equal to the amount used for the first JPG it will not further degrade the image — the damage has been done, but it’s not made worse. Nonetheless, for reasons too messy to explain here it’s my opinion that repetitive saves in JPG are almost always unnecessary and should be avoided.
|1st generation JPG of original||11th generation JPG|
The following is an illustration of what you get when minimal JPEG compression (75 in PhotoShop) is used. Now that you know what you’re looking for you can probably find the minimal JPG artifacts in the image on the right, but they’re fairly minor and you would certainly never see them in the actual size image.
|Original X3||Minimal JPG compression|
To demonstrate that you cannot tell the difference, the final two images below are similar to the two images above, except they’re normal viewing size — that is, not magnified. Like the above left image, the below left image has no JPEG compression. Like the above right image the below right image has been JPEG compressed, and by the same amount (75 in PhotoShop). I can’t see any difference. Can you?
|No JPEG compression||Minimal JPEG compression|
I end by repeating, lossless file formats maintain the full fidelity of your images, so by all means use them whenever practical. However, it’s my opinion that modest JPEG compression does not do serious damage to your images even if you compress/save the same image time and again.