Page 1 of 1

Re: check if a tiff file is almost white

Posted: 2009-06-10T15:09:05-07:00
by fmw42
Look at string formats, in particular the mean. If the mean is near quantum range (65535 on Q16 IM), then it is near white.

http://www.imagemagick.org/script/escape.php

convert -size 100x100 xc:white white.png
convert white.png -format "%[mean]" info:
65535

alternate result if near 1
val=`convert white.png -format "%[mean]" info:`
convert xc: -format "%[fx:$val/quantumrange]" info:
1

or
alternate convert to gray, scale to 1x1 pixels and get graylevel value of the one pixel

convert white.png -colorspace gray -scale 1x1! -format "%[fx:u]" info:
1