Parent document is top of "JPEG image compression FAQ, part 1/2"
Previous document is "[9] What are some rules of thumb for converting GIF images to JPEG?"
Next document is "[11] What is progressive JPEG?"

[10] Does loss accumulate with repeated compression/decompression?

It would be nice if, having compressed an image with JPEG, you could
decompress it, manipulate it (crop off a border, say), and recompress it
without any further image degradation beyond what you lost initially.
Unfortunately THIS IS NOT THE CASE.  In general, recompressing an altered
image loses more information.  Hence it's important to minimize the number
of generations of JPEG compression between initial and final versions of an
image.

It turns out that if you decompress and recompress an image at the same
quality setting first used, little or no further degradation occurs.  This
means that you can make local modifications to a JPEG image without material
degradation of other areas of the image.  (The areas you change will still
degrade, however.)  Counterintuitively, this works better the lower the
quality setting.  But you must use *exactly* the same setting, or all bets
are off.  Also, the decompressed image must be saved in a full-color format;
if you do JPEG=>GIF=>JPEG, the color quantization step loses lots of
information.

Unfortunately, cropping doesn't count as a local change!  JPEG processes
the image in small blocks, and cropping usually moves the block boundaries,
so that the image looks completely different to JPEG.  You can take
advantage of the low-degradation behavior if you are careful to crop the
top and left margins only by a multiple of the block size (typically 16
pixels), so that the remaining blocks start in the same places.

The bottom line is that JPEG is a useful format for archival storage and
transmission of images, but you don't want to use it as an intermediate
format for sequences of image manipulation steps.  Use a lossless 24-bit
format (PPM, PNG, TIFF, etc) while working on the image, then JPEG it when
you are ready to file it away or send it out on the net.  Aside from
avoiding degradation, you will save a lot of compression/decompression time
this way :-).

Parent document is top of "JPEG image compression FAQ, part 1/2"
Previous document is "[9] What are some rules of thumb for converting GIF images to JPEG?"
Next document is "[11] What is progressive JPEG?"