How to know if image is fully opaque

The MagickWand interface is a new high-level C API interface to ImageMagick core methods. We discourage the use of the core methods and encourage the use of this API instead. Post MagickWand questions, bug reports, and suggestions to this forum.
Post Reply
jmm72
Posts: 5
Joined: 2017-02-17T06:56:37-07:00
Authentication code: 1151

How to know if image is fully opaque

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: How to know if image is fully opaque

Post 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.
snibgo's IM pages: im.snibgo.com
jmm72
Posts: 5
Joined: 2017-02-17T06:56:37-07:00
Authentication code: 1151

Re: How to know if image is fully opaque

Post 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.
Post Reply