Page 1 of 1

check if image is transparent

Posted: 2018-06-28T16:43:01-07:00
by kiranbg123@gmail.com
How can I check if image is transparent in image magic++?
i am using im 6.9.6

image.matte() returns true even for non transparent images.
Can someone please help?

Thanks

Re: check if image is transparent

Posted: 2018-06-28T18:18:47-07:00
by fmw42
Use one of the properties that is equivalent to the command line string format %[opaque], which is shown at http://www.imagemagick.org/script/escape.php.

Sorry I do not use Magick++, so one of the other users or developers will need to help if you cannot figure that out.

Re: check if image is transparent

Posted: 2018-06-29T03:53:07-07:00
by snibgo
I'm not sure what test you want:

1. Whether or not the image is fully opaque.
2. Whether or not the image is fully transparent.
3. Whether or not the image contains any transparency.

For (1), use %[opaque].

For (2), find the minimum opacity (alpha). If this is 100%, the image is fully transparent.

For (3), find the maximum opacity (alpha). If this is 100%, the image has no transparency.