Do JPEG recompressions degrade images?

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
Silvestro Fantacci

Do JPEG recompressions degrade images?

Post by Silvestro Fantacci »

I am running a simple Magick++ application that does the following:

- Create a sample 8x8 Image X1.
- Set X1 type to JPEG.
- Set X1 quality to 95.
- Save X1 to Blob B.
- Create Image X2 from B.
- Set X2 type to JPEG.
- Set X2 quality to 95.
- Save X2 to B.
- Create Image X3 from B.

For quite a few sample images, X2 and X3 turn out to be different.

For instance, starting from this sample image: Image, it takes some 25 iterations to get to a stable state where the source and the target images are identical.

It looks a bit strange to me that the JPEG compression and decompression algorithms should not be "symmetrical".

Maybe I have made a mistake in my application... or has anyone else come across these kinds of results?
Silvestro Fantacci

Re: Do JPEG recompressions degrade images?

Post by Silvestro Fantacci »

I have found the answer here:
http://www.codinghorror.com/blog/archives/000629.html
I was also curious what the image quality and file size penalty was for recompressing a JPEG image. That is, opening a JPEG and re-saving it as a JPEG, including all the artifacts from the original compressed image in the recompression. I've been forced to do this when I couldn't find an uncompressed or high quality version of the image I needed, and I always wondered how much worse it made the image when I recompressed it. [...] I was quite surprised to find that there's very little visual penalty for recompressing a JPEG once, twice, or even three times. By generation five, you can see a few artifacts emerge in the image, and by generation ten, you're definitely in trouble. There's virtually no effect at all on file size, which stays constant at 30-31 kilobytes even through generation 15.
Post Reply