------ art_13943_25021471.1134475696124 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Please cancel this. On 12/13/05, Han Holl <han.holl / gmail.com> wrote: > > Hi, > > Because ruby-libexif no longer works with libexif-0.6.12, I decided to > roll my own Exif class. > Quick and dirty. > And got a surprising error message. > > Here's the program: > #!/usr/bin/ruby > > #require 'exif' > > class Exif < Hash > @@want = %w{ DateTimeOriginal DateTime ImageDescription PixelYDimension > } > def initialize(file) > > IO.popen("exiv2 -pt '#{file}'") do |h| > h.each do |line| > a = line.split[0].split(/\./)[2].strip > if @@want.include?(a) > self[a] = line[60 .. -1].strip > end > end > end > end > end > > def run > exif = Exif.new('/var/pictures/alpujaras/img_0528_edited.jpg') > puts exif['DateTimeOriginal'] > exif = Exif.new('/bin/ls') > puts exif['DateTimeOriginal'] > next if exif.empty? > puts "won't get here" > end > > run > ### End-of-ruby-program > > If I run this, I get: > 2005:01:04 13:22:48 > Exiv2 exception in print action for file /bin/ls: > /bin/ls: The file contains data of an unknown image type > nil > ./add_captions.rb:25:in `run': unexpected next (LocalJumpError) > from ./add_captions.rb:29 > > For a real JPEG it works fine, but things get ugly otherwise: > > I can't quite figure out what this means. > > Cheers, > > Han Holl > ------ art_13943_25021471.1134475696124--