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 - [12] Can I make a transparent JPEG?

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


Top Document: JPEG image compression FAQ, part 1/2
Previous Document: [11] What is progressive JPEG?
Next Document: [13] Isn't there a lossless JPEG?
See reader questions & answers on this topic! - Help others by sharing your knowledge
No.  JPEG does not support transparency and is not likely to do so any time
soon.  It turns out that adding transparency to JPEG would not be a simple
task; read on if you want the gory details.

The traditional approach to transparency, as found in GIF and some other
file formats, is to choose one otherwise-unused color value to denote a
transparent pixel.  That can't work in JPEG because JPEG is lossy: a pixel
won't necessarily come out *exactly* the same color that it started as.
Normally, a small error in a pixel value is OK because it affects the image
only slightly.  But if it changes the pixel from transparent to normal or
vice versa, the error would be highly visible and annoying, especially if
the actual background were quite different from the transparent color.

A more reasonable approach is to store an alpha channel (transparency
percentage) as a separate color component in a JPEG image.  That could work
since a small error in alpha makes only a small difference in the result.
The problem is that a typical alpha channel is exactly the sort of image
that JPEG does very badly on: lots of large flat areas and sudden jumps.
You'd have to use a very high quality setting for the alpha channel.  It
could be done, but the penalty in file size is large.  A transparent JPEG
done this way could easily be double the size of a non-transparent JPEG.
That's too high a price to pay for most uses of transparency.

The only real solution is to combine lossy JPEG storage of the image
with lossless storage of a transparency mask using some other algorithm.
Developing, standardizing, and popularizing a file format capable of
doing that is not a small task.  As far as I know, no serious work is
being done on it; transparency doesn't seem worth that much effort.

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: [11] What is progressive JPEG?
Next Document: [13] Isn't there a lossless 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