Sha256: 458ec86871ac40a737825b81121e7cde1a567d8fd4c432917ee9b81fc741d00f

Contents?: true

Size: 1.1 KB

Versions: 10

Compression:

Stored size: 1.1 KB

Contents

require 'exifr'
include EXIFR

def pp_jpeg(fname)
  jpeg = JPEG.new(fname)
  ks = %w(width height comment bits)
  ks += jpeg.exif.to_hash.keys.map{|a|a.to_s}.sort{|a,b|a<=>b} if jpeg.exif?

  l = []
  ks[0..3].each do |k|
    v = jpeg.send(k)
    l << [k, v.inspect] if v
  end
  ks[4..-1].each do |k|
    v = jpeg.exif.to_hash[k.to_sym]
    l << [k, v.inspect] if v
  end
  pp(fname, l)
end

def pp_tiff(fname)
  tiff = TIFF.new(fname)
  tiff.each_with_index do |img,index|
    l = []
    l << ['width', img.width] << ['height', img.height]
    img.to_hash.keys.map{|a|a.to_s}.sort{|a,b|a<=>b}.each do |key|
      l << [key, img.to_hash[key.to_sym].inspect]
    end
    pp(tiff.size == 1 ? fname : "#{fname}[#{index}]", l)
  end
end

def pp(fname, l)
  puts "#{fname}:"
  f = "  %#{l.sort{|a,b|a[0].size <=> b[0].size}.last[0].size}s = %s\n"
  l.each{|k,v|puts f  % [k, [v].flatten.map{|t|t.to_s}.join(', ')]}
end

if ARGV.size == 0
  STDERR.puts "Usage: #{$0} FILE .."
else
  ARGV.each do |fname|
    case fname
    when /\.(jpg|jpeg)$/i; pp_jpeg fname
    when /\.(tif|tiff)$/i; pp_tiff fname
    end
    puts
  end
end

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
bogado-exifr-0.10.8 bin/exifr
remvee-exifr-0.10.6.1 bin/exifr
remvee-exifr-0.10.7 bin/exifr
remvee-exifr-0.10.8 bin/exifr
exifr-1.0.0 bin/exifr
exifr-0.10.9 bin/exifr
exifr-0.10.5 bin/exifr
exifr-0.10.6 bin/exifr
exifr-0.10.8 bin/exifr
exifr-0.10.7 bin/exifr