Start by getting libimage-size. If you're using Ubuntu you can fetch it using
sudo apt-get install libimage-size-ruby
.You can now use the
ImageSize
class to fetch the width and height of your image. There are several ways of doing this, so here's one:open(image_path) do |fh|
img_size = ImageSize.new(fh)
end
puts "Width: #{img_size.get_width} Height: #{img_size.get_height}"