I'm embarking on what I believe may be somewhat of an experiment...
To come up with (or discover, as it could already exist) a method to determine whether a given image file, regardless of format, is a photo or a graphic.
"Photo" meaning something like scenery, people, etc. V.S. "Graphic" meaning an icon, illustration, chart, UI screenshot, etc.
I came up with a nice PHP / ImageMagick script in the past week which pulls statistics from image files and nicely applies fixes to white balance, tone, vibrance, sharpness, shadows/highlights.
Now I'd like to take it a step further: Automatically detect photo content, then apply the aforementioned processing.
One method which has worked somewhat-consistently so far was to determine if the image had EXIF data, but this only works on JPEGs. This isn't foolproof of course, though.
Are there any known methods via ImageMagick, GD or otherwise for detecting a "photo" vs a "graphic"?
I do have the capability of installing/running applications besides ImageMagick & GD on our web server if need be.
Thanks!
Photos tend to have a LOT of different individual colors in them (thousands, tenthousands and hundredthousands). Other graphics tend to rather use a limited number of unique colors (dozens up to a few hundred).
So an ImageMagick command may be able to help triaging a big number of files:
The special
%k
IMidentify
percent escape macro causes the counting and return of the number of unique colors in theidentify
ed file. Here are a few examples for my own local files:Running it against a set of 15
4032x3024
-sized photos in a local directory yielded this result (taking more than 2 seconds per photo to count the colors):Warning: sophisticated gradients produced with vector drawing applications, such as inkscape, may also produce lots of unique colors...