Thursday, September 8, 2011

Why You Shouldn’t Save JPEG Images in Quality 7 in Photoshop

When trying to resave a digital image in the JPEG file format, one is often required to make a decision as to what quality setting or level of compression to use. The JPEG (or JPG) format allows one to make a trade-off between file size and image quality by selecting an appropriate level of compression. But the scale used to indicate compression level is not consistent across all image editors or cameras. This is because there are thousands of different ways a JPEG image can be compressed, and software developers and camera manufacturers prefer to use methods they feel are right for their product. Some developers have even coded their own algorithms.

photoshop-quality7

While researching on JPEG image quality of different digital camera models and software image editors, developer Calvin Hass discovered a strange behavior in Adobe Photoshop CS2.

What many people don't know is that there is a quirk in the way that Photoshop defines its quality range. As mentioned earlier, Quality level 6 is the last point in which chroma subsampling is used. At Quality level 7 and higher, no chroma subsampling is used at all. With the amount of color information encoded now doubled, the file size would have naturally increased significantly at this level versus the previous level.

However, it is likely that Adobe decided to allocate the various quality levels with some relationship to the final compressed file size. Therefore, Adobe chose a poorer luminance and chrominance compression quality (i.e. higher level of compression) in Quality level 7 than Quality level 6! What this means is that the image quality of Quality level 7 is actually lower than Quality level 6 (at least from luminance detail perspective).

Let me explain that in plain English:

There are two type of information that needs to be saved in a digital image - information about brightness or luminance of each pixel on the image and information about color or chrominance of the pixels. The human eye’s ability to differentiate between colors is less than the acuity with which it can detect changes in brightness. The JPEG format takes advantage of this handicap by sampling the color information in the image at resolutions lesser than the one used for sampling brightness. This is known as chroma subsampling. With less color information to store, the size of the JPEG image is reduced.

Photoshop CS2 uses chrome subsampling for all quality levels lesser than, and including, 6. Starting quality level 7 and higher, no chroma sampling is used to improve color resolution and quality of the image. The flip side of discarding chroma sampling is that the amount of color information to encode  is now doubled and subsequently the file size is increased.

Adobe, not wanting the file size to make a giant leap when going from 6 to 7, decided to notch up the compression level in quality 7 to keep file size under check. This actually results in a lesser image quality in level 7 than in level 6!

So whenever you save image using Photoshop, don’t use quality 7. Either use 6 or 8 and above. Compared to quality level 7, images saved with quality level 6 have far better compressed image quality in both the chrominance and luminance channels.

Surprisingly, the poor chrominance information extends even to quality level 8. When quality level 6 is compared with quality level 8, images saved with quality level 6 is found to have better compressed image quality in the chrominance channels than images saved with quality level 8. But quality level 8 show better image quality in the luminance channel than quality level 6.

Now recall that the human eye has better resolution for brightness than for color. So quality level 8 appears better than quality level 6.

Conclusion

In short, if smaller file size is desired – use Quality level 6 or less. If higher quality is desired - use Quality level 8 or more. Don’t use Quality level 7.

Quality level 10 is the most anyone should use. Level 11 and 12 are there purely for experimental reasons (not much gain in quality for a large increase in file size).

For comparison of JPEG image quality see this page.

[Thanks Petapixel]

3 comments:

  1. Adobe Photoshop CS2? Isn't the version rather old? As in a decade? As in we are now using CS5? Which doesn't have any problems saving a 7 . . . CS2? OMG!

    ReplyDelete
  2. I'm not sure if CS5 has the same problem. Do you have any sources that support what you say - about this problem not existing in CS5?

    And yes, CS2 is old, but still good. Unless you use some specific CS5 features, I don't see why you should upgrade.

    ReplyDelete
  3. Useful post. I completely agree about sticking to known working versions too.

    Photoshop appears to have oddities in how it handles the JPEG format. Not entirely suprising, seeing how the program always sets rather than follows standards.

    Something related. Until at least 2012, Photoshop couldn't properly load JPEG files with chroma subsampling. It failed to correctly upsample the reduced resolution chroma with a smooth algorythm. Instead, chroma pixels were simply doubled, leading to blocky saturated colors, especially reds. I do not know if this is changed in the latest version. There are posts about it at Forums.Adobe.com as recent as from 2012.

    Prior to loading a JPEG file received from an unknown source, one must determine if subsampling is used, and, if it is, the file should be decompressed with a program that can correctly decode the chroma, such as a recent version of IrfanView. I find JPEGCrop to be particulary useful to quickly determine the subsampling level. To do so, drag a small cropping frame and observe if it can be expanded in units of 8 pixels or if the granularity is more rough, such as 16x16 or 16x8.

    I made a complaining remark on the official Adobe forum about this. But forum staff not simply disagreed with it, they "Rejected" the post from appearing. Now that is a bunch with their heads up their asses. And no, I didn't use improper language.

    ReplyDelete

Popular Posts