JPG or lossless for image archives?

A debate evolved recently on regarding the best format for image archiving. JPG was criticized for the image degradation of associated with this lossy image compression method. See How bad is JPG? for a summary of the limits of JPG.

Clearly when disk space is available, one should choose lossless formats at the highest resolution possible when archiving images. But what if disk space is not unlimited? Let's compare lossless PNG and lossy JPG at the same file size. How well does JPG stack up now?

At the same file size, JPG can support a much higher resolution scan. Consider the section of the photograph (a striped shirt ) that gave JPG so much trouble on the How bad is JPG page. I created two originals equivalent to scans at 96 dpi and 600 dpi, as shown below:

600 dpi scan, 139K PNG file:

96 dpi scan, 6K PNG file:

Applying even high quality JPG compression to the small image above results in severe image degradation, as described in How bad is JPG. (This particular color degradation is much, much less in Adobe Photoshop. See "Adobe JPG vs. PSP JPG.") The colors in the shirt are severely degraded, even at Paint Shop Pro's highest quality setting as seen in the JPG below:

Click for a magnified comparisonClick for a magnified comparison.

However, if what constrains us is file size, consider a 600 dpi file subjected to extreme JPG compression, resulting in a file size of 6K. This is a file no bigger than that of the 96 dpi scan saved in PNG. So how does it stack up? See below:

Not bad, huh? For a clearer comparison, below is a magnification of the 96 dpi scan stored in lossless format next to the 600 dpi scan stored with extreme JPG compression. The two files are the same size. Which do you think better retains more image information? If the original photograph was lost, which of the images below would you rather have?

Notice that at the higher resolution the colors of the stripes are maintained. The image on the right above is clearly superior. JPG works better on the higher resolution image, because what previously were abrupt transitions, the bane of JPG compression, are now smooth changes spread over multiple pixels.

May I suggest that JPG is better for archiving images than lossless formats when disk space is not unlimited? Scanning at higher resolution and compressing severely results in better images. Just do not fool yourself into thinking that you now have high quality at the full resolution of the severely compressed JPG.

Now we can view the JPG loss in context: sacrificing lossless encoding of the image may free us to retain more spatial resolution and perceived image quality (when limited by file size).

Scanning at higher resolutions may push the limits of your computer on large detailed images, so there may still be a place for low resolution lossless archiving. However, if you have the power, consider scanning at high resolution and then compressing with JPG.

DIGITAL CAMERA OWNERS: Most of the above discussion is irrelevant for images from digital cameras. You do not have the option of choosing a much higher resolution. A second point: if your camera saves only in JPG, be aware that loading the image into a graphics program and resaving as a JPG, even without editing the image, will degrade the image. Use the original JPG from the camera as your archival copy.

Please contact with comments or suggestions for improving this page.

Related web pages:

Rick Matthews' Home Page

Acknowledgments: Thanks to Tom Lane, organizer of the Independent JPEG Group, for corrections and helpful suggestions.