Is anybody aware of free software that can sort your pictures by overall color (or color of a specific region of an image)?

I've checked this question and looked into imgSeek, but the Mac version download links to a Japanese news site.

I've also tried the experimental feature in Picasa, but it 1) doesn't sort (it only searches) and 2) doesn't have a wide breadth of options to choose from.

  • What are you trying to accomplish with this? – mattdm Oct 11 '13 at 1:05
  • I have a directory full of images, and I'm hoping to somehow sort these images (so that, say, all of the predominantly red images appear first). Does that make sense? – Atticus29 Oct 11 '13 at 2:12
  • Sure, that helps. But, why? – mattdm Oct 11 '13 at 2:33
  • Because they are images of moths that I have to identify by species, and it will greatly help my workflow if similarly-colored moths are adjacent. – Atticus29 Oct 11 '13 at 14:53

ImageMagick is your friend

~> convert image.jpg -gravity center -crop 80x80%+0+0 -scale 1x1\! txt:-
# ImageMagick pixel enumeration: 1,1,255,srgb
0,0: (131, 89, 61)  #83593D  rgb(131,89,61)

This works by cropping away the outer 20% edge (gravity center indicates a crop of the outside edges). It then scales the image down to a single pixel and outputs that to the screen (if you replace the - at the end of the line with a filename you can write the output to a file). You can also experiment with resize/filter options, but scale is going to be quite a bit faster and for this application, I expect perfect.

Note that these values are Red/Green/Blue values, how you sort is another issue. You can pick the highest values and assume it is predominant, but that is probably not going to get the result you want, changing to either HSL or HSB is probably going to provide a more useful set of values for sorting:

~> convert image.jpg -gravity center -crop 80x80%+0+0 -scale 1x1\! -colorspace hsl txt:-
# ImageMagick pixel enumeration: 1,1,255,srgb
0,0: ( 19, 76,162)  #134CA2  hsl(7.46929%,29.8466%,63.5111%)


~> convert image.jpg -gravity center -crop 80x80%+0+0 -scale 1x1\! -colorspace hsb txt:-
# ImageMagick pixel enumeration: 1,1,255,srgb
0,0: ( 19, 75,190)  #134BBE  hsb(7.46929%,29.276%,74.4015%)

Sorting from here is not too difficult in shell script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.