I wanted to see which images I had in a directory that were a certain set resolution and decided to see how easy it was to do in ruby.

Turns out with a little

gem install image_size
  

It's pretty easy!

#!/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