Skip to content

Instantly share code, notes, and snippets.

@hamakn
Created October 17, 2014 10:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hamakn/5dfdeeb6dcbe5a99719f to your computer and use it in GitHub Desktop.
Save hamakn/5dfdeeb6dcbe5a99719f to your computer and use it in GitHub Desktop.
color space histgram of jpeg files
require "rmagick"
color_space_histgram = {}
files = Dir.glob(File.join(ARGV[0], "*.jpg"))
files.each do |file|
image = Magick::Image.read file
color_space_histgram[image.first.colorspace.to_s] ||= 0
color_space_histgram[image.first.colorspace.to_s] += 1
end
p color_space_histgram
# => {"sRGBColorspace"=>267}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment