Return to Digital Photography Articles
Resaving JPEG - Recompression Error In Photoshop
Resaving in Photoshop
Given all of the concern that digital photographers have over preserving their digital photos, most are now very well aware of the dangers of editing and resaving an image in a photo editor such as Photoshop. Thus, the interest in lossless edits (lossless rotation, lossless flip, lossless crop, etc.) was born. This article attempts to examine, quantitatively, the effects of repeated resaving on a digital photo from within Photoshop due to the nuances of JPEG compression. This should help put some perspective on the concerns people have over adding a generation or two of recompression error.
|Note the JPEG blocking artifacts from JPEG Resave|
Comparison Image Source
The following comparisons and measurements were taken from tests performed on a 6 megapixel digital photo from a Canon 10d in Fine mode. The image has a mixture of flat color, high detail regions and sharp lines. This combination lends itself well to an analysis of how JPEG compression and recompression affects different details in different amounts.
Visual Comparisons of Photoshop Resaving
In Comparison #1, you can see the effects of repeated resaving within Photoshop CS2 on a digital photo from a Canon 10d.
Comparison #1 shows a region of the original photo that contains large variations in color and luminosity.
We see that the higher quality settings used in Photoshop CS2 in the Save As dialog box lead to better overall image quality, even after repeated resaves.
Note a slight increase in noise in Save #10 in the case of the highest quality setting versus the first save.
This comparison region was chosen as it depicts almost flat lighting and minimal gradient across a large portion of the image.
You can see how high repeated saving at compression quality settings (e.g. Photoshop Quality 12) actually introduce significant noise into the final image.
In fact, the compression noise is much worse in the Quality 12 (Maximum) images than it is in the Quality 5 (Medium) setting! Although the noise is higher, the level of detail is still better in the Quality 12 over the Quality 5 (see the slanted line to the right). The lower quality settings introduces more blocking artifacts.
Aesthetically, one has to consider the tradeoff between preserving the original detail and introducing compression noise.
How to Resave in Photoshop with minimal image quality loss
By running JPEGsnoop on your JPEG image, you can determine what quality setting was used to save the original image (either with Save As or Save for Web). Choosing this same quality setting when you resave the image will greatly reduce the recompression error during the resave!
The following graph shows the amount of error that accumulates through repeated resaving of a digital photo within Photoshop CS2 at various quality settings. I have examined the relationship between the error (from the original) and the number of save operations ("generations").
Note that the following assumes the best case outcome from repeated resaving: not only is the same JPEG compressor / decompressor used (Photoshop CS2), but none of the image was modified between each resave. Obviously, any regions that underwent some degree of modification would see a degradation that exceeds the rate shown below.
I examine the resaving error for saves in three quality settings (Photoshop Quality 12, Quality 10 and Quality 8). For each generation (1 through 10), I compare the number of RGB values that differ between the original image and the resaved version. This is repeated for each of the three quality settings that I have tested. The difference between the original and the resaved version is represented by the percentage of RGB pixel comonents that differ.
|Graph of Cumulative Error vs # Resaves|
In addition to the percentage difference from the original, I have also plotted the mean RGB pixel component difference. A value of zero would indicate that all pixels in the resaved version were identical to those in the original. A value of 1 would indicate that, on average, every pixel in the image has shifted by 1 unit in the 8-bit component space (0..255).
When one examines the effects of repeated saves to a digital photo, some very interesting characteristics come to light.
- A higher compression setting (lower quality) leads to a bigger change in the first resave than the first resave with a lower compression setting (high quality). This is intuitive, as it is completely based on the wider differences in the quantization tables (PS Quality 12 vs Quality 5) and additional chroma subsampling.
- Repeated resaves at low compression settings (high quality) lead to progressively more pixels being different from the original photo. Again, this is to be expected.
- Repeated resaves at high compression settings (low quality) don't further add to the amount of pixels in error (i.e. different from the original). This is not particularly obvious. In fact, there is almost no difference in the number of affected pixels after the first save generation.
- Looking at the graphs of the pixel difference means shows us that repeated save generations at high compression settings does, however, increase the amount of error in each of these "erred" pixels.
- From the visual comparison above (#2), we see that repeated save generations at high quality settings actually leads to worse image quality through the introduction and magnification of compression noise. See Comparison #2 (Qual 12 - Save #10).