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!

Quantitative Results

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.

Observations:

  • 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).

 


Reader's Comments:

Please leave your comments or suggestions below!
2014-04-11 
 Oops! actually, what I meant was imoprt PNG/export DDS.I have some re-paints for V9 aircraft that suffer from lo-res. I was hoping to take the PNG files, tidy them up and export/save them as DDS but Photoshop CS5 won't accept any of the NVidia plug-ins.Having read some more since the previous post, I'm assuming that DDS.XGrinder is the way to go? Sorry to give you palpitations as I graphic designer I'm well up on the wrongness of back and forths on lossy formats
2009-05-31Joen
 I love your program, Cal. I have a few questions:

Is it possible to tell how many times a .JPG has been resaved in Photoshop CS2 by examining the final image?

Blocking artifacts cause shifts in the detail of an image; i.e, short, straight horizontal lines are broken into small blocks that alternately shift up and down.

How are these blocking values indicated in the output of JPEGSnoop?
 Thanks Joen -- It is not at all easy to determine how many times an image has been recompressed, especially if you don't have access to the original file. Even with the original image for comparison purposes, there are virtually limitless combinations of JPEG output compression quality settings that could have been used during resaving. I believe that the sequence order and value of each Save As quality setting will impact the blocking artifact characteristics seen in the final image. JPEGsnoop does not currently perform blocking artifact detection, but this is on my list -- as it can assist with certain image forensics analysis approaches.
2006-11-26Tom Aird
 I am totally ignorant about Photoshop, et. al. This is the first article about that included RGB values that I could understand, and I believe it is because of the photos and charts accompanying the text. Very powerful. I was asked to submit photos that were rgb.jpg format and I didn't have a clue as to what the man was talking about.
 Thanks Tom -- I'm happy to hear that it was useful!

 


Leave a comment or suggestion for this page:

(Never Shown - Optional)
 

Visits!