[NTG-pdftex] PNG handling, transparency

Hartmut Henkel hartmut_henkel at gmx.de
Mon Nov 1 18:09:35 CET 2004


There is a problem (by libpng 1.2.7) with PNG inclusion and alpha
channel. Greg Roelofs from the png-implement list gave an external
workaround

> pngtopnm foo.png | pnmtopng > foo-no-alpha.png

Tried it, works. I see how the PNG images with alpha channel "really"
should look like: different from what pdftex maybe ever tried to do.
Previously the alpha channel was simply stripped. Now certain images are
blended to a uniform background (its color might be part of the PNG
file, or come separately through the -mix -background option to
pngtopnm).

But the whole rectangular image area is still opaque, so it hides things
underneath.

As replacement for the (currently a little buggy) libpng now one could
probably adapt the pngtopnm program to get an integral part of pdftex.

Now should one just flatten a PNG with alpha so that it blends to an
opaque white background (or the one provided with the image), in the way
the above external processing does? Then there is no way to supply the
background color if it's missing in the image.

Apart from this PNG opaque blending, there is also the "Transparency"
feature in PDF (PDF Ref. chapter 7). Looks complicated. Has anybody ever
played with transparency, e. g. by some \pdfliteral tricks?

Or should one stay away from all this alpha and transparency business,
flag an error on PNG's with alpha (they likely look wrong anyway), and
recommend that alpha needs the shown preprocessing?

Maybe it also helps just to do nothing and wait for libpng 1.2.8...

Regards, Hartmut


More information about the ntg-pdftex mailing list