JPEG Images: Counting your Losses
Standard and "Not so Standard" Formats
Digital photos can be stored in many formats such as JPEG, TIFF, PNG, PSD, PCD and many others. It is important to understand the limitations of each format so that you can select the proper format for the job at hand. This article focuses on the costs and benefits of using the JPEG format, so we won't go into all of the other possible formats in detail, at least not in this article. Of all the dozens of popular formats, some are proprietary and others are considered "international standards". Using a format that is an international standard ensures that you and the people with whom you share images will be able to display them without needing additional software in most cases. Three of the most popular "international standard" formats used on the web are JPEG, TIFF, and GIF. GIF is limited to 256 colors and is used most often to display screen shots and graphs and should not be used for photographs. The remaining formats, JPEG and TIFF, both have their place in digital photography and there are pros and cons to both formats.
Lossy and Lossless Formats
TIFF, often saved with a TIF file extension, is a lossless format. Lossless means that when the image is saved and later reloaded, each pixel in the saved/reloaded image is identical to the image before it was saved. As such, there are no quality losses, but the size of the file can be quite large because the RGB values for each pixel are recorded verbatim. Compressed TIFF's offer a size savings just as WinZip offers size savings for files, without introducing quality loss but even compressed TIFF's are usually larger than JPEG images.
JPEG on the other hand, is a lossy format. Lossy means that compromises are made to allow some image quality to be lost each time the image is saved. In return for the slight quality loss, the file size can be much smaller, on the order of 2-10 times smaller than a compressed TIFF. When an image is saved in the JPEG file format and later reloaded, the saved/reloaded image will not be identical (pixel to pixel) to the original before it was saved. Fortunately, the quality losses can be very difficult if not impossible to detect with the unaided eye after only a single save. Keep in mind that repeatedly opening and resaving JPEG photos will incur cumulative losses with each save, making quality worse each time you resave the JPEG.
Understanding "Compression" and "Quality"
When saving JPEG images, you will normally have a choice of either "quality" or "compression". The higher the compression, the lower the quality because when you compress more (to reduce file size), quality decreases. Just remember that if your photo editor lets you choose "quality" for your JPEG's, higher values will produce bigger files with higher quality. If, on the other hand, your JPEG options include "compression", higher values for "compression" will result in smaller files of lesser quality.
Getting a Handle on Quality Losses
There are two types of losses associated with saving JPEG images. The first type of loss is simply related to the parameters you use when you save the file: set your compression too high or your quality too low, and your images will look worse. The second type of losses are "generational" losses. Generational losses occur when you repeatedly open and resave JPEG files, opening a file, saving it, opening the second copy, saving it to a third file, etc. The greater the number of times you save the JPEG (from a previous copy), the worse your images will look. The first time you save an image to a JPEG, it can be considered a "first generation" JPEG. If you open that first generation JPEG and resave it, the resaved file can be considered second generation since it has gone through the JPEG lossy saving method twice. Remember that losses only occur in the saving process. Repeatedly opening an already saved JPEG without resaving it (modifying it) isn't going to cause losses in quality. Losses are only incurred when you use the "File", "Save" or "Save As" command and you choose "JPEG" as the file type.
Examples of JPEG Quality Loss
Here is an example that demonstrates visible loss of image quality due to saving the same image at different quality settings. The following images were saved using PhotoShop and quality settings between 0 (low quality, small files) and 12 (highest quality, largest file size). As you can see, the lowest quality produces the smallest file size but there are highly visible artifacts in the image such as color blotching, pixelization, and posterization (banding) of colors. As you increase quality, these artifacts start to disappear, but file size increases as an inevitable cost. Note that once you get to about quality 10 or higher, it is nearly impossible to distinguish between the JPEG and the original image (before saving to JPEG) for most images. As a result, as long as you save at a high quality (low compression) setting, JPEG is certainly a valid format for a "first generation" save and can rarely be distinguished from a lossless save such as a TIFF image as long as a high quality setting is used.
|Save Quality||File Size||Result|
Below is an example of "generational losses" from opening and resaving in the JPEG format. Notice that quality is very reasonable for the first few saves but losses become evident beyond about 5 saves depending on the quality setting used. Below, "generation" indicates how many times the JPEG has been resaved based on saving copy 1, opening copy 1 and saving copy 2, opening copy 2 and saving copy 3, etc. Notice how the generational losses are less evident when you save each copy with a higher quality setting. The quality differences are more subtle with generational losses when compared to simply picking the wrong quality level (above), but by the 10'th generation, obvious blotching and color changes are occurring.
|Generation||Save Quality 10||Save Quality 12|
What about JPEG 2000?:
There is a newer and less [visibly] lossy version of the JPEG format known as JPEG 2000, often saved with a J2K or JP2 file extension. The JPEG 2000 format has similar issues when compared to the JPEG format but to a lesser degree. In addition, the JPEG 2000 format offers a "lossless" mode in which images can be saved without any quality loss, but with a somewhat larger file size. In general, JPEG 2000 offers higher quality than JPEG when comparing the same saved file size. So why not use JPEG 2000? Many people are, however, JPEG 2000 is not as widely supported and is generally much slower than JPEG. In addition, if you have a camera and you shoot in JPEG mode where your camera delivers a JPEG file on the memory card, there is no benefit to resaving those JPEG images to JPEG 2000 images since that will incur further quality losses over the original JPEG, unless you use the lossless JPEG 2000 mode which will serve to do nothing but increase file size over the original JPEG. In general, JPEG is just easier to use, more portable, faster, and can be readily displayed quickly on the web, in email clients, and other third party applications. With time, JPEG 2000 decoders will get faster, will be more widely available, and more tools will support them, possibly even some future cameras. So far, the JPEG 2000 format really hasn't "taken off" in the industry like was anticipated, but time will tell.
What's the Bottom Line?:
The JPEG image format offers a way to save images using less space, but with some loss in image quality. Typically, a first generation save will be almost as good as a lossless TIFF as long as you use quality levels close to the highest available. Some "die hards" claim that you should never use a camera in JPEG mode when you have TIFF or RAW available as an option, and one cannot argue that you get the best quality and best editing capability with TIFF or RAW when compared to JPEG. That said, JPEG is a perfectly valid format to use even when capturing images the first time in your camera, especially when memory space, shooting speed, or the ability to print images without post processing is important. Remember that JPEG's are processed and ready to view/print, whereas RAW images require post processing to "develop" the images from the raw data. This takes additional time and can complicate your shoot-to-print workflow. A first generation JPEG will offer quality comparable to any other final or ready-to-print format, however, cannot offer latitude for correcting exposure and other shooting issues like a RAW image or a 48 bit TIFF. Bottom line: choose what works for you, but be sure to take the pros/cons of each format into consideration.
-- Mike Chaney