08-02-2008 19:28
I keep seeing confused statements about PNG, transparency, and alpha channels repeated on the SL forums, this is a (probably futile) attempt to clear the fog.

A complete reference for the PNG format can be found at http://www.w3.org/TR/PNG/ but here we'll stick to the salient bits.

PNG offers 5 color modes (there are no types 1 or 5, the number is a bit mask) and three different kinds of transparency (W3C mentions 4, but that's about compaction techniques and not the encoding). The color modes and channels are:

0. Grayscale: gray.
2. Truecolor: red, green, blue.
3. Indexed color: palette index (like GIF).
4. Grayscale with alpha: gray, alpha.
6. Truecolor with alpha: red, green, blue, alpha.

Formats 4 and 6 are easy to explain, those have full-fledged alpha channels. Format 6, truecolor with alpha, is what you get when you save a normal transparent Photoshop _RGB_ image as PNG. It is also what you get for PNG-24 with transparency from Save for Web… (These, incidentally, are the types of PNG files that Internet Explorer handled badly for years.)

Formats 0 and 2, the grayscale and truecolor without alpha, can define a single color or gray value to appear as transparent (that is, you get fully opaque or fully transparent, no in between). This is very much like how transparency worked in the ancient GIF89a. You aren't going to see these very often.

Format 3, the indexed color scheme, is a strange hybrid. You can define a different alpha value for each color in the palette, every pixel of the same color will have the same alpha. This is what you get if you save an _indexed color_ transparent image from Photoshop's Save As…, or use Save for Web… with PNG-8 and transparency on. You probably won't run into this unless your source image was something like a GIF and you didn't change the mode to RGB.

----------------

So, how can you tell what kind of transparency is in a particular PNG file? Most graphics programs will tell you if there's transparency there, but is there a regular alpha or one of these weird variations? One simple tool is grep. If you grep the PNG for tRNS, then you have one of the transparency schemes for formats 0, 2 and 3. PNGs with real alpha channels (and those with no transparency at all) will not have tRNS chunks.

----------------

So, if PNG has proper alpha channel support, why doesn't Photoshop expose it? It's just a user interface thing. You can certainly get there using layer masks, perhaps they though it better to force a WYSIWYG approach with newer file formats. Too bad they didn't do this in a way that would give consistent results no matter what format was used to save the image.

A third-party replacement for Adobe's PNG save module, called SuperPNG, used to let you define a freestanding alpha channel and use it in the same way as Photoshop's native Targa plugin works, but inexplicably that feature was removed from the latest version and now it works like Adobe's.

Oddly, another Adobe acquisition, the former Macromedia Fireworks, uses PNG as its native format and lets you access that alpha channel with wild abandon.

----------------

But in summary, don't worry about having an alpha channel in your PNG files. If you are working in a normal high color format in Photoshop, your PNG's transparency will be saved in a real alpha channel, and SL's JPEG 2000 conversion will preserve that.
_____________________