File: print_portraits.rb

package info (click to toggle)
ruby-mini-exiftool 2.9.0-2
  • links: PTS
  • area: main
  • in suites: bookworm, bullseye, buster, forky, sid, trixie
  • size: 688 kB
  • sloc: ruby: 2,616; makefile: 2
file content (27 lines) | stat: -rw-r--r-- 664 bytes parent folder | download | duplicates (3)
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