[magick-users] Detecting transparency

Fred Weinhaus fmw at alink.net
Fri Feb 6 20:08:36 PST 2009


This is also equivalent and may make more sense to use -channel a 
rather than -channel o.



transparency=`convert yourimage -resize 1x1 -alpha on -channel a 
-format "%[fx:u.a]" info:`

examples:

convert -size 100x100 xc:black -resize 1x1 -alpha on -channel a 
-format "%[fx:u.a]" info:
1

convert -size 100x100 xc:none -resize 1x1 -alpha on -channel a 
-format "%[fx:u.a]" info:
0

convert -size 100x100 gradient: -alpha copy -resize 1x1 -alpha on 
-channel a -format "%[fx:u.a]" info:
0.499992





More information about the Magick-users mailing list