[magick-users] Detecting transparency

Dodger el.dodgero at gmail.com
Fri Feb 6 23:36:52 PST 2009


Would there be any way to do this in the PerlMagick API, though?

I'd really rather not write out to disk and sling backticks. It's bad form.

-- 
Dodger

2009/2/6 Fred Weinhaus <fmw at alink.net>:
> test for transparency as follows. if result is 1, then totally
> opaque, if result is 0, then totally transparent.
> Thus any result less than 1 has some transparency.
>
>
> transparency=`convert yourimage -resize 1x1 -alpha on -channel o
> -format "%[fx:u.a]" info:`
>
> examples:
>
> convert -size 100x100 xc:black -resize 1x1 -alpha on -channel o
> -format "%[fx:u.a]" info:
> 1
>
> convert -size 100x100 xc:none -resize 1x1 -alpha on -channel o
> -format "%[fx:u.a]" info:
> 0
>
> convert -size 100x100 gradient: -alpha copy -resize 1x1 -alpha on
> -channel o -format "%[fx:u.a]" info:
> 0.499992
>
>
>
> _______________________________________________
> Magick-users mailing list
> Magick-users at imagemagick.org
> http://studio.imagemagick.org/mailman/listinfo/magick-users
>



-- 
Dodger


More information about the Magick-users mailing list