JPEG Iterations

Effects of repeated JPEG compression

This is a quick demonstration of what happens when JPEG is applied repeatedly to an image. It shows how the images change with successive iterations even at the maximum quality settings. The test data is designed to be impossible for default 2x2 colour subsampling to give an accurate rendition of the original image. The target is a single 8x8 block chosen for its simplicity of appearance and difficulty of JPEG encoding. If it was reproduced at normal size you would find it very difficult to distinguish between either of the first generation copies without the aid of a zoom function.

Life size versions are tiny so here is a table with the first generation copies and the original at shown 1x, 2x, 4x magnification.

Zoom Original JPEG 2x2 chroma JPEG 1x1 chroma
x1 original ijg99gen1.jpg gen1p10.jpg
x2 original ijg99gen1.jpg gen1p10.jpg
x4 original ijg99gen1.jpg gen1p10.jpg

The first generation JPEG images are both tolerable provided that the resulting image is not subject to excessive enlargement. To emphasise the differences I will use a higher magnification factor of 10x linear size for the tests below.

Repeated compression with PaintShop Pro v5 (IJG codec) at maximum quality. Each successive image has been decoded from the previous generation of data and saved as a maximum quality JPEG with default 2x2 chroma subsampling. There is a huge hit on the first iteration with this line artwork because there is so much fine blue and red detail. Colour contrast is gradually lost with each successive iteration. After a total of 5 iterations the image converges on a solution that is self consistent and stable, though lacking fine detail colour contrast.

Convergence on an attractor like this is less likely in real photographic images at highest quality, but does sometimes occur with them at moderate qualities.

Original Generation 1 Generation 2 Generation 3 Generation 4 Generation 5
Image original ijg99gen1.jpg ijg99gen2.jpg ijg99gen3.jpg ijg99gen4.jpg ijg99gen5.jpg
Colours 4 25 33 58 63 61

ref_ijg1.gif ijg1_ijg2.gif ijg2_ijg3.gif ijg3_ijg4.gif ijg4_ijg5.gif
Peak error
154 8 5 3 0

Notice how the second and subsequent generations suffer loss of colour contrast through the 2x2 block colour averaging. The extent of the loss surprised me. I think a lot of the generational losses attributed to JPEG are actually down to multiple applications of the chroma subsampling rather than the JPEG algorithm itself.

I should point out that the latest version of Paintshop Pro v8.0 supports a wide range of settings for colour subsampling and not just the basic default 2x2.

Repeated compression with PhotoShop v5.0 (Adobe codec) at maximum quality (10/10) with 1x1 colour sampling. More recent versions have 12 compression levels. You will work hard to spot the difference visually between these and the original target image. The chosen target image is intended to be easy to judge by eye. If you look very carefully you should be able to see a slight checkerboard ripple on the top line of the image. After a total of 6 iterations this test image also converged on a stable attractor. No further changes will occur after this stage .

Original Generation 1 Generation 2 Generation 3 Generation 4 Generation 5 Generation 6 Generation 7
Image original gen1p10.jpg gen2p10.jpg gen3p10.jpg gen4p10.jpg gen5p10.jpg gen6p10.jpg gen7p10.jpg
Colours 4 31 37 40 40 41 44 44

ref_gen1.gif gen1_gen2.gif gen2_gen3.gif gen3_gen4.gif gen4_gen5.gif gen5_gen6.gif ijg4_ijg5.gif
Peak error
5 2 2 2 1 1 0

The settings used by PhotoShop for its highest quality JPEG saves do not cause obtrusive artefacts in the first generation, and only cause a very slight loss after the second iteration. The damage is subtle enough that I have included a contrast stretched version below that preserves the original colours but emphasises deviations from them. Armed with the knowledge of where to look and a sufficiently zoomed image you should now be able to see the small artefacts introduced above at generation 2 and higher.


It works surprisingly well on line art considering it was never intended to be used in this way. It is quite a useful means of archiving scanned data in a more compact form than TIFF.

JPEG is much better at compressing normal photographic images accurately than this rather difficult test image. The worst errors occur in the initial step from the original and represent a peak error of 5 in 150 or 3% and an rms error of about 3 in 150 or 2%. After that successive re-compressions at identical settings contribute a cumulative error of less than 1% per iteration.

Email to Martin Brown {short description of image}

Send feedback suggestions and comments to Martin Brown
Last modified 24th January 2013