|

楼主 |
发表于 2015-4-30 16:12:23
|
显示全部楼层
Section - [12] Can I make a transparent JPEG?
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. |
|