check if image is transparent

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
kiranbg123@gmail.com
Posts: 5
Joined: 2018-06-28T15:02:22-07:00
Authentication code: 1152

check if image is transparent

Post by kiranbg123@gmail.com » 2018-06-28T16:43:01-07:00

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

User avatar
fmw42
Posts: 24013
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: check if image is transparent

Post by fmw42 » 2018-06-28T18:18:47-07:00

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.

snibgo
Posts: 10845
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: check if image is transparent

Post by snibgo » 2018-06-29T03:53:07-07:00

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.
snibgo's IM pages: im.snibgo.com

Post Reply