in reply to check if image is monochromatic
Having said that, one way of doing it (untested):
my @out = `djpeg $file.jpg | ppmhist`; splice @out, 0, 2; if (@out == 2 && ($out[0] =~ /^\s*0+\s+0+\s+0\s/ && $out[1] =~ /^\s*255\s+255\s+255\s/ || $out[0] =~ /^\s*255\s+255\s+255\s/ && $out[1] =~ /^\s*0+\s+0+\s+0\s/)) { ... is black-and-white ... } else { ... has colours that are neither black, nor white ... }
|
|---|