Page 1 of 1

TIFF RGBA to INT-A turns alpha channel into transparency?

Posted: 2013-04-29T08:57:04-07:00
by chrisell
Hello.
I've scoured the forums for a couple of days now and found multiple topics that all seem to skirt around the issue, but none that answer my question:
How can I convert an image to TIFF format and preserve the alpha channel?

Windows 7, ImageMagick-6.8.5-Q16
This is my basic CLI:

convert aircraftwheel_side_b.tif -grayscale Average newwheel.tif

The input file has RGBA channels. The output file I'm expecing to have Grey/Alpha channels but comes out as a grey channel with transparency "baked in" and no alpha channel (in Photoshop).
I've seen topics discussing TIFF headers, "extrasamples" bits and all manner of other things I don't understand. I'm just trying to batch-convert 20-something-thousand images from colour to black and white whilst maintaining the alpha channels where they exist and so far I'm drawing a blank.

I'd even go so far as extracting the alpha as a matte and piping it back into the greyscale (converted with no alpha) as an additional channel but I can't get my head around the format of the piping functions in IM. (for example, separate matte, convert original image to grey without alpha, add matte image into resulting grey image as an alpha channel)

Any help would be appreciated. Thanks in advance!

Original image is here:
https://dl.dropboxusercontent.com/u/315 ... side_b.tif

What I get out of IM:
https://dl.dropboxusercontent.com/u/315 ... -i-get.tif

What I actually want (manually created in PS to illustrate):
https://dl.dropboxusercontent.com/u/315 ... i-want.tif

Re: TIFF RGBA to INT-A turns alpha channel into transparency

Posted: 2013-04-29T09:38:42-07:00
by fmw42
Both of the following work fine for me in IM 6.8.5.3 Q16 Mac OSX Snow Leopard.

convert aircraftwheel_side_b.tif -grayscale average aircraftwheel_side_b_ave.tiff
or
convert aircraftwheel_side_b.tif -set colorspace RGB -colorspace gray aircraftwheel_side_b_gray.tiff


I can open them in Photoshop and it has an alpha channel, though disabled as is the input image. One has to enable it.

You probably need to have the alpha channel in PS enabled and then save it so that it is on by default. But when I try it in my old PS CS the save transparency checkbox in the Tiff Options panel is grayed out and I cannot figure out how to ungray it.

Re: TIFF RGBA to INT-A turns alpha channel into transparency

Posted: 2013-04-29T10:49:15-07:00
by chrisell
Hmm.
Using those CLIs still gives me the 'baked in' transparency. My original image, in PS, shows as 4 channels - r,g,b and a. The resulting image only ever shows a single channel.
It's not just PS either - I use a couple of 3D modeling tools (Max, Maya etc) and they all fail to see any alpha channel in the resulting image.
There IS transparency, but it's not split out into its own channel.
Also of note : if I do the same conversion to .PSD file, the same thing happens - "baked in" transparency instead of separate alpha channel.
I'm on my third day of trying to figure this out now - I didn't think it would be this difficult. It's like IM doesn't know how to turn the matte from the original image into a corresponding matte in the new image.
Fred - after you do your conversion - any way you can share the file so I can try to open it this end and see if I see what you see?

Re: TIFF RGBA to INT-A turns alpha channel into transparency

Posted: 2013-04-29T12:36:20-07:00
by fmw42
I do not believe the issue is with IM but with PS. It keeps the alpha channel hidden in tiff format.

Here is what I did.

I opened your image in PS and found that the alpha channel was off as you can see below.

Image


So I enabled it and saved the file to tiff. Here is the save panel showing alpha is checked.

Image


But then when the Options panel opens before saving, I cannot check save transparency, since it is grayed out. I cannot find a way to enable it.

Image


Nevertheless, I saved the tiff copy (notice here when displayed, the alpha channel is active, at least in my Safari browser)

Image


When I reopen it in PS, it still shows the alpha channel as off

Image


Here is the grayscale converted tiff (notice here when displayed, the alpha channel is active).

convert aircraftwheel_side_b_copy.tif -grayscale average aircraftwheel_side_b_copy_grayscale.tif
Image


But it also opens in photo shop with the alpha channel turned off.

Image


However, if you convert the tiff to png, then it is saved with the alpha channel showing.

convert aircraftwheel_side_b_copy.tif -grayscale average PNG32:aircraftwheel_side_b_copy_grayscale.png
Image




NOTE: In PS, when the alpha channel is enabled, it shows a red background. If you want to set the image so that it has a red background under the transparency, then

convert image.tif -background red -alpha background newimage.tif

But that will not show the red background unless you flatten the image.

Re: TIFF RGBA to INT-A turns alpha channel into transparency

Posted: 2013-04-29T12:49:36-07:00
by chrisell
Fred
Yeah - TIFs get saved with the alpha even if it's "turned off" in the channel list. The channel list in Photoshop is showing you all the channels available in the image - been working with PS since version 2 so I'm intimately familiar with it :)

What's odd is that those screenshots you show are exactly what I EXPECT to see. But what I'm getting is this - this is what I mean by "baked-in" transparency.
The source image shows correctly as RGB and A channels in photoshop, but the result from IM is this odd hybrid type that LOOKS like it ought to be a PNG but is a TIF:

Image

Because photoshop is showing the files correctly before they go through IM, that's why I don't think it's a Photoshop settings. It's only after IM has touched the files that the alpha channel disappears. Also - I have other tools and programs that show it the same way - without an alpha channel (mostly 3D modeling tools) so they can't work with the resulting image either.

But now I'm curious how you were able to run the same command and get a valid second channel instead of the PNG-style hybrid transparency. Can you send me the file you created so I can try to open it here and see what it shows me?

Re: TIFF RGBA to INT-A turns alpha channel into transparency

Posted: 2013-04-29T12:51:31-07:00
by fmw42
Just download it from the displayed images above.

Re: TIFF RGBA to INT-A turns alpha channel into transparency

Posted: 2013-04-29T12:58:12-07:00
by chrisell
fmw42 wrote:Just download it from the displayed images above.
Wow. Weird. I downloaded the TIF and it shows as the 'hybrid' style in my PS and my modelling tools, yet on your side it shows as separate alpha channels. So now I suspect there's something in the header that isn't being set that MAC PS doesn't care about but PC PS does (or vice versa).
At the bottom of this topic (http://www.wizards-toolkit.org/discours ... =3&t=22037) you mention the 'extrasamples' field but I don't see any way that IM can alter that? Or am I barking up the wrong tree?

Re: TIFF RGBA to INT-A turns alpha channel into transparency

Posted: 2013-04-29T13:09:48-07:00
by chrisell
I just did an itentify -verbose on the image that IM gives me versus the same image manually edited to have a separate alpha channel, and diff'd the two results. The only things that show up different in the manually edited version are these:

tiff:document: gray.tif missing from the IM version
tiff:rows-per-strip: 128 set to 32 in the IM version
Profiles: all missing from the IM version
Profile-8bim: 6488 bytes
Profile-xmp: 14375 bytes

Re: TIFF RGBA to INT-A turns alpha channel into transparency

Posted: 2013-04-29T13:55:17-07:00
by fmw42
It could be a change in PS. I am using a very old PS CS. What version are you using? Also what version of IM are you using?

Re: TIFF RGBA to INT-A turns alpha channel into transparency

Posted: 2013-04-29T14:14:14-07:00
by chrisell
ImageMagick-6.8.5-Q16 with Photoshop CS5.

It's like there's something buried in the TIFF header that is making PS think this image has premultiplied alpha when it shouldn't.
I just tried it in CS3 - same as you - it shows up with a separate alpha channel. Stranger and stranger.
Now what is interesing is that one of the 3d modelling packages I use has a rudimentary texture editor in it, and this is how those converted textures show up:

Image
It's like something got byte-swapped or something - rows and columns the wrong way around or the wrong number of bits. Photoshop CS3 seems able to handle this but CS5 and the 3D modeling tools I use clearly can't.

Re: TIFF RGBA to INT-A turns alpha channel into transparency

Posted: 2013-04-29T16:11:53-07:00
by fmw42
Actually I am on PS CS, even earlier than CS3.

In PS you can set the endian, via the tiff options panel to Mac or PC. You might try saving it the other way and see what happens.

Re: TIFF RGBA to INT-A turns alpha channel into transparency?

Posted: 2015-11-23T11:25:27-07:00
by rondublin
Hi Chrisell

Did you ever get a work around for this? I am having the exact same issue trying to resize a bunch of tiffs with Alphas. The alpha channel is gone in the output tif. Very annoying. Any luck yourself? I am also using cs5 and the latest version of image magic. Thanks in advance

Re: TIFF RGBA to INT-A turns alpha channel into transparency?

Posted: 2015-11-23T11:51:48-07:00
by fmw42
rondublin wrote:Hi Chrisell

Did you ever get a work around for this? I am having the exact same issue trying to resize a bunch of tiffs with Alphas. The alpha channel is gone in the output tif. Very annoying. Any luck yourself? I am also using cs5 and the latest version of image magic. Thanks in advance

What is your exact command line? What IM version and platform? Can you post your image to some place such as dropbox.com, so we can test with it?

Re: TIFF RGBA to INT-A turns alpha channel into transparency?

Posted: 2015-11-23T12:32:27-07:00
by rondublin
Hi

Trying in on pc and at home on a mac. Same results. Below is the mac information as im not in work now. The alpha channel is present in the source image and not in the 'out' image. I have tried many different flags to no avail. (alpha, separate/composite etc). I simply want to resize and keep the alpha channel. An exact copy of the file at a new size is what i require.

Thanks

mac version -
Version: ImageMagick 6.9.1-5 Q16 x86_64 2015-06-13

command
convert Hills.tif -resize 1024 Hills_out.tif

file link
https://drive.google.com/file/d/0B9k_-C ... sp=sharing

fmw42 wrote:
rondublin wrote:Hi Chrisell

Did you ever get a work around for this? I am having the exact same issue trying to resize a bunch of tiffs with Alphas. The alpha channel is gone in the output tif. Very annoying. Any luck yourself? I am also using cs5 and the latest version of image magic. Thanks in advance

What is your exact command line? What IM version and platform? Can you post your image to some place such as dropbox.com, so we can test with it?

Re: TIFF RGBA to INT-A turns alpha channel into transparency?

Posted: 2015-11-23T12:44:53-07:00
by fmw42
I do not see any problems running your command on IM 6.9.2.6 Q16 Mac OSX. I get transparency in the output!

What do you get from

Code: Select all

convert -version
Does it list tiff? If so, what version?

Code: Select all

convert -list format
TIFF* TIFF rw+ Tagged Image File Format (LIBTIFF, Version 4.0.3)

Perhaps you need to upgrade libtiff.