Saving an image file in the JPEG format is a commonly used method of "lossy" compression for digital photographic images. The degree of compression can be adjusted, allowing for a user selectable tradeoff between storage size and image quality. The greater the image compression the smaller the resulting image file and the greater the loss of image quality.
By default, images are JPEG compressed when saved as a PDF file.
How JPEG compression works
JPEG compression works by chunking similar image pixels that have slightly different color values into groups of pixels with the same color value.
The above original image file size is 1.5 MB.
The same image file saved at highest compression/lowest quality is only 92 KB. (Note: this level of extreme image compression would never be used in production work.)
Subtracting the pixels of the original image from the JPEG image reveals where pixels are different. Note that large areas of no detail like the sky have been chunked into large pixel groupings while areas of fine detail have been chunked into smaller pixel groupings.
The resolution of the original image impacts the effect of JPEG image compression
On the left is the original high resolution image. On the right is the JPEG version. Note that the JPEG artifacts are barely visible.
On the left is an original medium resolution image. On the right is the JPEG version. Note that the JPEG artifacts have become visible.
On the left is an original low resolution image. On the right is the JPEG version. Note that the JPEG artifacts are now very visible.
Bottom line - high resolution images can tolerate a greater degree of compression than low resolution images.
Resaving images, even edited images, in JPEG format does NOT reduce quality further
The original image saved at highest compression/least quality to exaggerate the effects of JPEG compression.
The same image resaved 15 times at the highest compression/least quality. The image was altered before each save to force recompression.
Subtracting the pixels of the original image from the 15th version of the resaved JPEG image reveals where pixels are different. Note that only the areas where the image was altered are different despite being resaved 15 times with high compression/low quality. All other pixels are the same.
Resaving images that have been cropped DOES reduce quality further
On the left is the original image saved with high compression/low quality. On the right is the same image that has been cropped and resaved with the same high compression/low quality setting. Cropping the image causes the chunking of pixels during compression to be redone and introduces artifacts.
Subtracting the pixels of the original image from the cropped version of the resaved JPEG image reveals where pixels are different.
Bottom line - multiple resaves of images with JPEG compression has no effect on pixels (image detail) that have not been edited. Pixels that have been edited will be "chunked" to the same degree as the pixels in the original image. In other words, images do not degrade after multiple resaves using JPEG compression.
The most common level of compression used does NOT result in any visible image degradation.
Click images to enlarge
Original image at left - high quality/low compression on right (Photoshop level 12)
Original image at left - high quality/low compression on right (Photoshop level 10 - the most common level of JPEG compression)
Original image at left - medium quality/medium compression on right (Photoshop level 8)
Original image at left - medium quality/high compression on right. (Photoshop level 6)
Subtle image degradation is becoming visible.
Original image at left - low quality/high compression on right. (Photoshop level 4)
Image degradation is becoming visible.
Original image at left - very low quality/very high compression on right. (Photoshop level 2)
Image degradation is clearly visible.
Original image at left - extremely low quality/extremely high compression on right. (Photoshop level 0)
Image degradation is obvious
Bottom line - at typical JPEG compression levels there is no visible degradation of the original image. In fact, one has to go to unusual levels of compression before artifacts are seen (at least level 8 in Adobe Photoshop).
Images with lots of small detail compress less and mask JPEG artifacts better than images with large smooth tone areas.
Double bottom line - there is no reason to be concerned about saving images in JPEG format so long as the highest quality/least amount of compression option is selected.
Special blog production note.
Unless otherwise stated, all "Original" images were low resolution images. JPEG compression was "0" (lowest quality/highest compression). It was the only way to exaggerate the difference enough to demonstrate the issues. If I had used the actual original images - 14 megapixels in this case - the differences would mostly have been invisible. Note that the Blogger website compresses the images that I upload so there will be compression artifacts in the posted "Original" images that were not in the images that I uploaded.
I strongly encourage you to repeat any of these tests yourself with your own images to confirm, or contradict, my findings.
I'm not suggesting that you use JPEG as your preferred image file type. My intent is only to show how saving an image in the JPEG file format introduces, or does not introduce, artifacts and hopefully shed a light on some commonly held beliefs about this image file format.
After some tests my end, I confirm everything stated in this article except one (don't worry, this is rather good news): There is absolutely no loss after resaving a cropped image many times!
ReplyDeleteI'm using PS CS5 extended, JPEG level 12 Baseline "standard" format
Thx for the subtracting layer tip and the nice article!
Just because you can't see it on one picture doesn't mean you can't see it on others. Stuff with an isolated image on a white background will artifact to hell and back on high settings. As an artist, JPG creates tons of visible artifacts on the first save for anything below level 10. Of course, I'm LOOKING for them, and I absolutely loathe them. Still though, just because it's fine for you, doesn't make it fine for everybody. At least I can ignore anything that shows on 11, but if you go back to do editing after the fact, hoo boy, have fun with that crap. Fill will never be the same. JPG was great for the dial-up era. Move on. Use PNG when it is suitable (and that's remarkably a lot of the time)
ReplyDelete