Skip to content

Instantly share code, notes, and snippets.

@ajbonner
Created June 24, 2011 16:58
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 ajbonner/1045193 to your computer and use it in GitHub Desktop.
Save ajbonner/1045193 to your computer and use it in GitHub Desktop.
Get the dimensions of an image using ruby's image_size gem
#!/usr/bin/env ruby
require 'image_size'
pwd = File.dirname(__FILE__)
Dir.glob(pwd+'/*') do |file|
if (File.extname(file) == '.jpg')
fh = File.open(file, 'rb')
size = ImageSize.new(fh.read)
puts "[#{size.w}x#{size.h}] #{file}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment