Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 28 lines (25 sloc) 0.664 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
# -- encoding: utf-8 --
require 'rubygems'
require 'mini_exiftool'

unless ARGV.size > 0
  puts "usage: ruby #{__FILE__} FILES"
  puts " i.e.: ruby #{__FILE__} *.jpg"
  exit -1
end

# Loop at all given files
ARGV.each do |filename|
  # If a given file isn't a photo MiniExiftool new method will throw
  # an exception this we will catch
  begin
    photo = MiniExiftool.new filename
    height = photo.image_height
    width = photo.image_width
    # We define portait as a photo wich ratio of height to width is
    # larger than 0.7
    if height / width > 0.7
      puts filename
    end
  rescue MiniExiftool::Error => e
    $stderr.puts e.message
  end
end
Something went wrong with that request. Please try again.