LocalJumpError

H

Han Holl

------=_Part_13867_29040675.1134475160901
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

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 =3D %w{ DateTimeOriginal DateTime ImageDescription PixelYDimension=
}
def initialize(file)

IO.popen("exiv2 -pt '#{file}'") do |h|
h.each do |line|
a =3D line.split[0].split(/\./)[2].strip
if @@want.include?(a)
self[a] =3D line[60 .. -1].strip
end
end
end
end
end

def run
exif =3D Exif.new('/var/pictures/alpujaras/img_0528_edited.jpg')
puts exif['DateTimeOriginal']
exif =3D 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

------=_Part_13867_29040675.1134475160901--
 
H

Han Holl

------=_Part_13943_25021471.1134475696124
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Please cancel this.

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 =3D %w{ DateTimeOriginal DateTime ImageDescription PixelYDimensi= on
}
def initialize(file)

IO.popen("exiv2 -pt '#{file}'") do |h|
h.each do |line|
a =3D line.split[0].split(/\./)[2].strip
if @@want.include?(a)
self[a] =3D line[60 .. -1].strip
end
end
end
end
end

def run
exif =3D Exif.new('/var/pictures/alpujaras/img_0528_edited.jpg')
puts exif['DateTimeOriginal']
exif =3D 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

------=_Part_13943_25021471.1134475696124--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,139
Latest member
JamaalCald
Top