I'd like to use imagemagick or graphicsmagick to detect whether an image has basically no content.
Here is an example:
I've scoured Fred's imagemagick scripts, but I can't figure out if there is a way to do this:
I'd like to use imagemagick or graphicsmagick to detect whether an image has basically no content.
Here is an example:
I've scoured Fred's imagemagick scripts, but I can't figure out if there is a way to do this:
If you are talking about the amount of opaque pixels vs the amount of transparent pixels, then the following will tell you the percentage of opaque pixels.
convert test.png -alpha extract -format "%[fx:100*mean]\n" info:
39.0626
Or if you want the percentage of transparent pixels, use
convert test.png -alpha extract -format "%[fx:100*(1-mean)]\n" info:
60.9374
Easiest way would be to use -edge detection followed by histogram: & text:. This will generate a large list of pixel information that can be passed to another process for evaluation.
The above example will generate a nice report of:
As the count of white pixels is less then 1% of black pixels, I can say the image is empty.
This can probably be simplified by passing -fx information to awk utility.