2002.03.25 18:37 "Photoshop TIFF+Alpha mysteries", by Chris 'Xenon' Hanson

2002.03.25 19:20 "Re: Photoshop TIFF+Alpha mysteries", by Chris Cox

First - you are confusing transparency with alpha channels.

Alpha channels are a superset: they can be many things, only ONE of which is transparency.

A transparency channel is a subset of possible alpha channels (one which is associated with the image data).

Maybe this is an FAQ.

We use LIBTIFF in our software, and I am forever grateful for the brain aneurysms it has prevented for me.

In several places in our software we support the use of an Alpha channel to indicate transparency amounts when compositing various images together.

For example, I use Photoshop 5.5 to open a vector-based logo file I have lying around. I set RGB Color, and anti-aliased. It converts it to a raster image with transparency (but no Alpha channel). Fine.

Just save as TIFF, there is no need to add an alpha channel or flatten - because you already have transparency.

Now, I do Select/Load Selection, choose Layer 1 Transparency and New Selection. Now, Select/Save Selection, New Channel, named "Alpha". Now I flatten the image.

Ok. I appear to have an Alpha channel. Here I can do one of two things.

I can save it as a 32-bit Targa file or I can save it as a TIFF file.

In Photoshop 5.x, Targa used alpha channels instead of transparency. Thus it's using your blank alpha channel for the Targa file.

If I save it as Targa, it works fine in my app. The NULL areas where there was no logo are interpreted as transparent.

If I save it as TIFF, it doesn't exactly work. The areas that are transparent in the TGA are opaque.

Because you flattened the image and added an alpha channel. Lord only knows what your software is actually reading for the transparency.

A few pixels along the border between the logo and the background area appear to become transparent.

Loading the working TGA file back into Photoshop and resaving it as a TIFF appears to make a similarly non-working TIFF. Resaving the non-working TIFF as a 32-bit TGA makes a working TGA file.

So, the actual Alpha 'channel' data in Photoshop is presumably identical in all of the images. Perhaps Photoshop interprets that Alpha channel data as it loads/saves to TIFF? Perhaps LIBTIFF is interpreting that Alpha channel data differently as I load it? I'm not sure. All I know is that from the API side of things, I have all indications that there is an alpha channel in the TIFF image I load, yet when I go to use it in the way I am accustomed to, it doesn't work the way i expect. I expect I'm missing some small detail.

Yep - you're confused.

I've been thinking my next step is to add a a bit of debugging code to my LIBTIFF loader to write the alpha channel out to a raw file so I may examine it and see what exactly I'm getting out of LIBTIFF. However, I suspect this is already a commonly-encountered problem and someone can just point me at an answer I have overlooked.

I considered that it might be an difference of premultipled versus non premultipled alpha, but since the image data itself is the same, I can't see how this could be.

There is no transparency in your TIFF image - because you flattened the image. If there was transparency, then the TIFF would have an associated alpha channel and the color data would be premultiplied with white (white matted).

Chris