Search the FAQ Archives

3 - A - B - C - D - E - F - G - H - I - J - K - L - M
N - O - P - Q - R - S - T - U - V - W - X - Y - Z
faqs.org - Internet FAQ Archives

JPEG image compression FAQ, part 1/2
Section - [10] Does loss accumulate with repeated compression/decompression?

( Part1 - Part2 - Single Page )
[ Usenet FAQs | Web FAQs | Documents | RFC Index | Schools ]


Top Document: JPEG image compression FAQ, part 1/2
Previous Document: [9] What are some rules of thumb for converting GIF images to JPEG?
Next Document: [11] What is progressive JPEG?
See reader questions & answers on this topic! - Help others by sharing your knowledge
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.

There are a few specialized operations that can be done on a JPEG file
without decompressing it, and thus without incurring the generational loss
that you'd normally get from loading and re-saving the image in a regular
image editor.  In particular it is possible to do 90-degree rotations and
flips losslessly, if the image dimensions are a multiple of the file's
block size (typically 16x16, 16x8, or 8x8 pixels for color JPEGs).  This
fact used to be just an academic curiosity, but it has assumed practical
importance recently because many users of digital cameras would like to be
able to rotate their images from landscape to portrait format without
incurring loss --- and practically all digicams that produce JPEG files
produce images of the right dimensions for these operations to work.  So
software that can do lossless JPEG transforms has started to pop up.  But
you do need special software; rotating the image in a regular image editor
won't be lossless.

It turns out that if you decompress and recompress an image at the same
quality setting first used, relatively little 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 something like 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.  (True
lossless cropping is possible under the same restrictions about where to
crop, but again this requires specialized software.)

The bottom line is that JPEG is a useful format for compact 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 (PNG, TIFF, PPM, etc) while working on the image, then JPEG it when
you are ready to file it away or send it out on the net.  If you expect to
edit your image again in the future, keep a lossless master copy to work
from.  The JPEG you put up on your Web site should be a derived copy, not
your editing master.

User Contributions:

Comment about this article, ask questions, or add new information about this topic:

CAPTCHA




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

Part1 - Part2 - Single Page

[ Usenet FAQs | Web FAQs | Documents | RFC Index ]

Send corrections/additions to the FAQ Maintainer:
jpeg-info@uunet.uu.net





Last Update March 27 2014 @ 02:11 PM