2002.03.25 18:37 "Photoshop TIFF+Alpha mysteries", by Chris 'Xenon' Hanson
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.
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.
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. 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.
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.
Thanks in advance for any advice. I still think LIBTIFF is the cat's meow, and I'm very grateful for it's existence (and LIBGEOTIFF as well) because they made my life much easier.
Chris - Xenon
Chris Hanson | Xenon@3DNature.com | I've got friends in low latitudes!
New Visual Nature Studio 1.1: http://www.3DNature.com/
"There is no Truth. There is only Perception. To Perceive is to Exist." - Xen