Roland's homepage

My random knot in the Web

Does repeated JPEG conversion reduce quality?

Recently, in a comment on freethoughtblogs.com, it was posited that repeated rewriting of a JPEG file causes quality loss.

To test this, I started out with a photo that I made myself, and rewrote it ten times using convert from the ImageMagick suite:

> convert original.jpg gen1.jpg
> foreach n (`seq 1 9`)
  @ m = ($n + 1)
  convert gen${n}.jpg gen${m}.jpg
  end
> ll original.jpg gen*.jpg | awk '{print($6, $10)}'
92987 gen10.jpg
93013 gen9.jpg
93008 gen8.jpg
93009 gen7.jpg
93013 gen6.jpg
92995 gen5.jpg
92989 gen4.jpg
92993 gen3.jpg
92997 gen2.jpg
92985 gen1.jpg
93042 original.jpg

It is important to know that the original image has a JPEG quality setting of 80%. This is also the default for convert.

Original image:

Original image

Tenth generation copy:

Tenth generation copy

Visually, I do not see a lot of difference.

Next, I generated the difference between the original and the 10th copy:

> compare original.jpg gen10.jpg -compose src diff.png

The file diff.png is shown below. Red pixels differ between the two images, white pixels are the same.

Difference between original and tenth generation copy

The red pixels are concentrated in rectangular blocks. This has to do with how JPEG compression works.

Conclusion

Repeated re-writing at quality setting 80% causes some slight differences after ten generations. But visually, there is almost no difference.


For comments, please send me an e-mail.


←  Testing compression speed and ratio Patching CalculiX Graphics to fix flipped screen hardcopy  →