Do you know what quality level to use when saving an image as JPEG?

Do you know what Adobe Photoshop (or any other application that saves JPEG images) is doing when it asks for the compression level?

JPEG compression is one of the best ways to save an image. You can reduce images sizes more than 1/3 their original size with almost no visual loss in quality. That is the key here -- visual loss. File compression is the process of reducing a file size using certain encoding methods. JPEG takes advantage of the fact that your eye may not be able to see the differences in color changes and effectively changes an image so it can create a smaller file. This is lossy compression and will result in an image that is not bit for bit the same as the original. Also note that every time you open and resave a JPEG image, you recompress the image. The cool part is that you will probably not notice this recompression if you pick the correct quality setting.

Adobe Photoshop has quality levels from 0 to 12. 0 will give you the smallest file and look terrible. 12 will save the image very close to the original. The following images and descriptions should help you decide what is best for you. I usually stick to a quality level of 8. This seems to be about the point where you start to see a few artifacts, but is still very close to the original. Note that previous version of Adobe Photoshop and other image editors may use a different scale for their quality setting.

First, lets look at how much an image changes (or does not change) recompressing the same image multiple (10) times.

Each image is 108 kbytes. I would suggest you don't download these. They all look the same to the eye, but they are here if you really want proof.

Original (1st Gen), 2nd, 3rd, 4th, 5th, 6th, 7th, 8th, 9th, 10th

What is interesting is if we compare the 1st generation with the 2nd, 5th, and 10th. Below is an animated image that uses Adobe Photoshop's "Difference" calculation to compare the images. The original image is set as the background layer. The compressed image is in a layer above it and set to "Difference". An adjustments layer of type "Levels" was added above that and adjusted until the changes could be seen. (If the levels were not adjusted, the entire image would be black, meaning that the changes are VERY SMALL!)

To look at some major areas of change, I have extracted a few areas that looked to have the most changes. You can click on the images to view a zoomed in version of the comparisons in another window. This compares generation one (top) to generation ten (bottom).

1 2 3

As you can see, recompressing images ten times really does not change an image much. It is still a good idea not to continuously recompress an image. The best way to work with an image is to save as an uncompress Adobe Photoshop document (.PSD) so that all your layers, styles, masks, transparency, etc. are saved, then save as a JPEG for your final output. If you want to play around with the compression using your own images, use Adobe Photoshop's "Save for Web..." option and select the 2-up or 4-up mode with different compression settings. Adobe Photoshop 6 also gives you a preview on the compression when you do a regular save as JPEG. You can zoom in on your image and toggle the "Preview" checkbox to see the changes.

Now, we get to something very interesting. Click on the image below (332 kbytes) to view in another window for a more detailed look. This is a "difference" on the same image compressed at a quality of 8 and 12 with the levels adjusted to see the changes. This is a pretty cool image. You can see that quick changes in color have more loss than smooth color changes. Look especially at the shapes at the bottom on the image. High contrast color changes are not compressed well as a JPEG, even at a high quality setting, although it is useable. Keep that in mind when you save a scanned document with a mix of text and photo content.