Sorting images based on colors

Started by stan, May 23, 2015, 03:47:26 PM

Previous topic - Next topic

stan

I have a folder full of images in various formats (BMP, TIF, JPG, GIF, ...). In decreasing order of preference I'd like to sort the images into separate folders based on the following criteria:

1) Number of colors in each image (i.e. folders for images with 1 color, 2 colors and so on)

2) Range of colors in each image (i.e. folders for images with 1-10 colors, 11-20 colors and so on)

3) 3 folders - Black & White, grayscale and colored

4) 2 folders - Black & White plus grayscale and colored

I can't figure out the -if criteria for this. Is it even possible with ExifTool?

StarGeek

Quote from: stan on May 23, 2015, 03:47:26 PM
Is it even possible with ExifTool?

For the most part, not, not really.  ExifTool deals with with the metadata, not so much with the contents of the actual image, though it does give some info.

It all depends upon the file type.  For example, GIFs have a limited number of colors and you could get how many colors are in the palette with ExifTool, but that doesn't guarantee that all those colors are used.  In theory, you could tell if a JPG is grayscale or full color, but I believe that digital cameras still save the file as full color even when the camera takes a b/w picture.

You'll probably have to look into scripting something up with a different program.  Off hand you might check out ImageMagick's Identify.  I believe identify -format "%k" FILE will give the approximate number of colors in an image.  Also, Color Quantization and Dithering might have some useful examples on figuring out color content.
* Did you read FAQ #3 and use the command listed there?
* Please use the Code button for exiftool code/output.
 
* Please include your OS, Exiftool version, and type of file you're processing (MP4, JPG, etc).

stan

I will take a look at ImageMagick then, thank you.