[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

LocalJumpError

Han Holl

12/13/2005 11:59:00 AM

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
1 Answer

Han Holl

12/13/2005 12:09:00 PM

0

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
>