Skip to content

Instantly share code, notes, and snippets.

@aereal
Created March 6, 2011 19:11
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 aereal/857556 to your computer and use it in GitHub Desktop.
Save aereal/857556 to your computer and use it in GitHub Desktop.
Collect statistics of F-numbers from my photos.
#!/usr/bin/env ruby
# -*- encoding: utf-8 -*-
f_numbers = Dir.glob("**/*.jpg").map {|jpg|
`jhead #{jpg}`.gsub(%r{Aperture\s*:\s*(?:f/(\d+(?:\.\d+)?))}) { $1 }
}.compact.map {|f| f.to_f }
f_numbers.group_by {|f| f_numbers.count(f) }.each do |freq, f|
puts "#{freq}: #{f.uniq.join(",")}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment