detecting transparent gif
Posted: 2009-04-10T11:18:23-07:00
Using Imagick, how can I detect if a gif is transparent or not?
I tried the following using getImageChannelDepth(imagick::ALPHA_CHANNEL), but did not work for me:
if (result is zero or null) // API doc only says "TRUE on success" which I think should be the number of bits for that channel and API does not say the return value if that channel does not exist
{
this is NOT a transparent gif
}
else
{
this is a transparent gif //has 1 bit alpha channel
}
However, I tried this on a transparent and a non-transparent gif. Both return 1 bit depth for alpha_channel (both return types are int using is_int to check). Using the command line identify, only the transparent gif has alpha channel info that shows 1 bit though. Could this be a bug with Imagick?
But anyways, I just need to know how to detect the transparent gif. I am using Imagick 2.2.2RC1 and ImageMagick 6.2.9 12/17/07 Q16
I tried the following using getImageChannelDepth(imagick::ALPHA_CHANNEL), but did not work for me:
if (result is zero or null) // API doc only says "TRUE on success" which I think should be the number of bits for that channel and API does not say the return value if that channel does not exist
{
this is NOT a transparent gif
}
else
{
this is a transparent gif //has 1 bit alpha channel
}
However, I tried this on a transparent and a non-transparent gif. Both return 1 bit depth for alpha_channel (both return types are int using is_int to check). Using the command line identify, only the transparent gif has alpha channel info that shows 1 bit though. Could this be a bug with Imagick?
But anyways, I just need to know how to detect the transparent gif. I am using Imagick 2.2.2RC1 and ImageMagick 6.2.9 12/17/07 Q16