Page 2 of 2

Re: Problem with convert - tiff to jpg

Posted: 2010-04-23T09:29:12-07:00
by snibgo
So you want to disregard the transparency in one image, and convert the transparency in the other to white? Yes, you need two different commands.

Re: Problem with convert - tiff to jpg

Posted: 2010-04-23T10:28:34-07:00
by zaratol
So to put it short: There is no way of handling Image transparency and alpha channel transparancy differently?

I feared as much, thank you all for your time

Re: Problem with convert - tiff to jpg

Posted: 2010-04-23T14:50:35-07:00
by fmw42
I don't think that is the case. Your alpha2.tif image seems to have some extraneous alpha channel that shows only the lid. How did that get there? Why is it there? Perhaps for some other purpose. Perhaps someone added that to purposely show only the top. It is extraneous for your purpose. How was this created and why was the alpha channel placed on the alpha2.tif image? Is this a regular situation or a one time issue?

Do you have other cases that fall into this situation? if so, post a link to one or more of them.

The real issue here is that in your transparent.tif image you have a black background area that is not part of the image under the alpha channel. In the alpha2.tif image you have real image under the alpha channel. These are two completely different situations. In the first case you want to change the background to white. In the second case, you do not want to change what is under the alpha channel to white unless you only want to see the top. You probably want to see the real image under the alpha channel and in that case you have to simply remove the alpha channel. Using the same method for both will produce only the top or lid in alpha2.tiff and make all the rest of the image under the alpha channel white.

So again you have two different situations in the image under the alpha channel and it depends upon the reason the alpha channel was created in the first place and what is under it as to how you ultimately want to process the image.

Re: Problem with convert - tiff to jpg

Posted: 2010-04-26T01:30:24-07:00
by zaratol
The alpha channel "Alpha 1" was created for image editing purposes only.

I don' t need it in the resulting images, but neither i'm allowd to just delete them in the original.
And yes it is a rather common situation. All images in question were manually edited, but not in all of them where alpha channels used for that purpose.

For the moment i have to asume, that are alpha channels in the image that are not needed anymore. Not for the results i want to achive.

As you described i want the whole image, in both cases. I also expiremented with the "-channel" command, to adress only the specificly created alpha channels but so far it had not the desired effect. Maybe there is a way to extract the image in some way?

Re: Problem with convert - tiff to jpg

Posted: 2010-04-26T10:23:24-07:00
by fmw42
try

convert alpha2.tif -channel A -evaluate set 100% +channel alpha2_opaq.tif


This will leave the alpha channel but make it totally opaque.

Re: Problem with convert - tiff to jpg

Posted: 2010-08-12T06:38:55-07:00
by zaratol
no that didn't work.

I think this is related to:viewtopic.php?f=1&t=16629

Anyway I'm now using a shell script checking alpha Information:

IDENTIFYVERBOSE=$( identify -verbose $FILE )

echo $IDENTIFYVERBOSE | grep -q 'Alpha: none'
NOALPHA=$?
ALPHAOFF=
if [ 1 -eq $NOALPHA ]; then
ALPHAOFF=" -alpha off "

And so far this works for me. I still think you should be able do distinguish between transparancy information (associated or unassociated) and "alpha masks". Well what in Photoshop is called alpha masks.
Ideal you should be able to activate/deactivate each alpha mask individually.

Re: Problem with convert - tiff to jpg

Posted: 2010-08-12T10:07:27-07:00
by Drarakel
zaratol wrote:Anyway I'm now using a shell script checking alpha Information:
...
That might work for some cases (coincidentally), but surely not for every case.

You should use ExifTool to check for the masks that you don't want to use in ImageMagick:

Code: Select all

exiftool -S -s -n -IFD0:ExtraSamples <file>
If '0' gets returned, then it's "unspecified alpha" (no normal alpha layer, just e.g. a mask). In that case you can add "-alpha off". The value '1' is for "associated alpha" and '2' for "unassociated alpha".

Something like that was also the result from the linked thread (but Fred only needed "associated alpha" IIRC).