How bad is JPG?

Warning: the images on this page total 1.5 Megabytes. There is a reason for this. Detailed images stored in lossless format have large file sizes. Please be patient.

There has been much criticism of JPG as a "lossy" format. Lossy compression means that the image is allowed to change (degrade) in order to achieve smaller file sizes. How much does JPG compression degrade image quality? Well, it depends.

Much of the criticism of JPG compression is in fact a criticism of implementation choices by software authors. JPG is capable of remarkable compression with very little degradation in quality. First let's examine the kind of problem that produced disappointment in some JPG users.

I scanned a very detailed image, and saved it using the lossless PNG format. Next I performed a JPG compression using rather low compression but also following the near-universal approach of chroma subsampling.

This page was originally posted as a challenge in the Paint Shop Pro Usenet discussion group.I chose this image because of its mixture of fine detail and large areas of nearly uniform color. I scanned it nearly twice the rendered size and resized it to what you see. After that, I applied the Paint Shop Pro "sharpen" function, which makes things a bit more challenging for JPG.

The original is rendered as a PNG, a lossless compression algorithm. My apologies for the large file size, but the size is a consequence of picking a detailed image and saving it in a lossless format. If you find the first image below unviewable, please drop me a note at matthews@wfu.edu and tell me what browser and version you are using.

(There are known bugs in PNG rendering in all versions of Internet Explorer. IE users are encouraged to upgrade to Mozilla.)

The original PNG:

The JPG:

The good news: the images are hard to distinguish without very close inspection, and the file size of the JPG is only 29% the size of the uncompressed PSP original and less than half the size of the PNG. Most portions of the image look identical even under extreme maginfication. However, if you know where to look, you can find a few spots with significant differences.

Below is a magnification of the region with the most dramatic difference. Look closely at the red and blue striped shirt of the gentleman kneeling at lower left of the above images. In magnification the colors of the JPG are not nearly as bright. Below are blowups of the original (on left) and the JPG (on right).

This kind of problem is often cited by critics of JPG. However, the above is really a criticism of only one JPG approach to reducing file size. It is a manifestation of chroma subsampling, where color information is stored at only half the resolution of the intensity information. A few programs, most notably Paint Shop Pro, make chroma subsampling optional. Below at right is shown the same section of the image under JPG compression without chroma subsampling. It is nearly indistinguishable from the original:

So how bad is JPG? Not bad at all! It is a lot better than most people think, especially at low compression settings, and especially with chroma subsampling turned off.

However, it is important to remember that JPG is designed for photographic images. Computer generated images with sharp transitions between areas of uniform color are particularly difficult for JPG to handle. (See JPG vs GIF.) Also, colored stripes that are only one pixel wide, as in the above image, cause problems for the great majority of graphics programs that force subsampling of chroma information in 2x2 blocks. For best JPG quality, it is absolutely essential to use a program such as Paint Shop Pro that allows the user to disable chroma subsampling.

See "Chroma subsampling in JPG images" for a more complete discussion of the effects of chroma subsampling. (Paint Shop Pro offers the user full control of chroma subsampling; Adobe Photoshop turns off chroma subsampling on or off based on the quality setting.)

Another way of comparing JPG and lossless formats is to compare at the same file size. The case for JPG is strong under this constraint. See "JPG or lossless for archiving?" for a striking comparison.

Important warning to readers: loading and saving a JPG repeatedly will accumulate the small errors introduced, so that the image can seriously degrade. Working copies of images should be kept in a lossless format. When you are through with your manipulations, you may then save to JPG once, with minimal loss of quality. Also, please note that not all graphics programs do an equally effective job of JPG compression. Although there is a unique way of displaying a JPG, creating the JPG involves choices that some programs make better than others. For illustrations of this effect, see C. White's page.

Please contact matthews@wfu.edu with comments or suggestions for improving this page.

Acknowledgements: