JPEG Compression — Devil or Angel?

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.


5 Responses to “JPEG Compression — Devil or Angel?”

  1. Johno Says:

    This all sounds pretty reasonable. The artifacts in JPEG come about from the approximations in fitting to particular combinations that are possible in JPEG with a certain number of pixels. Thus, using the same encoding algorithm again and again by opening and saving will result in exactly the same file. The uncertain thing is more when there are significant changes made to the image, such as doing a curves adjustment over the whole image or a rotation/scale. In that case it will have to be re-fitted to a different represenation, and is thus open to another round of degredation. It is a bit harder to do objective tests on such a scenario though.

  2. berk Says:

    There are other ways to reduce file size without resorting to extreme JPEG compression (I define as 30+% compression). When I shoot, I start with the highest JPEG setting on my camera. I have the option of shooting RAW, but I don’t know how to utilize that and it’s not important for my hobbyist needs. I make a copy and archive the original. With the copy, I first reduce the DPI from 300 to 72 since I am only displaying on the web and not printing them. Next, I’ll reduce the physical size of the image to about 1000 x whatever (gets it close to the resolution of my monitor). Just these two steps shaved a huge chunk off file size. I usually save the JPEG to 80-85%. The initial JPEGs start at 2-4 mb and end up at 150-250k.

  3. .i dream in red. Says:

    Cool article. Thanks for the link on your site. I shall return the honor. =D

  4. picturation Says:

    Hi Johno

    I agree. Changes to the image will result in a different JPEG compression and thus a different result. I intended to mention that in the article. But, as you also say, it’s difficult to devise a way to test the extent of this effect.

    Years ago, before I learned about JPEG losses, I had an image I modified and saved many times. At the time I didn’t noticed any harm done by this repeated change and save. But, I was less descriminating then. 🙂

  5. picturation Says:

    Thanks, red dreamer

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: