Page 1 of 1

How to know if image is fully opaque

Posted: 2017-02-21T17:16:57-07:00
by jmm72
Hello everyone.

I used to list images with a batch file specifying %[type] and %[opaque] (returns true if all pixels are fully opaque, false otherwise) in -format. If image was TrueColorAlpha and opacity was true, then the alpha channel was empty (fully opaque image) and could be discarded.

I want to achieve the same through MagickWand, but other than MagickGetImageAlphaChannel to know if image has an alpha channel, I'm lost. I don't seem to find any equivalent function of %[opaque]. Is there any function I can use? Or do I have to iterate each pixel and check its opacity? In that case, is it possible to iterate somehow through the alpha channel's values directly?

Regards, JMM

Re: How to know if image is fully opaque

Posted: 2017-02-21T17:34:11-07:00
by snibgo
In attribute.c, function IsOpaqueImage(). This works by testing every pixel for being opaque, because there is no other way of doing it.

Re: How to know if image is fully opaque

Posted: 2017-02-22T05:28:28-07:00
by jmm72
I'm doing it with PascalMagick, so I'm limited to whatever is translated from the headers of MagickWand interface. I guess I'm having to do it myself with iterating through pixels. I guess it'll be about the same speed, I just wanted an easy way through an already made function. Thanks.