Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readlong': undefined method unpack' for nil:NilClass (NoMethodError) #20

kyanny opened this issue Jul 21, 2011 · 1 comment


Copy link

kyanny commented Jul 21, 2011

EXIFR::TIFF::Data#readlong throws exception for this image file.

This photo was taken by Galaxy S camera in consinuous shooting mode.

backtrace is below.

$ exifr ~/daniel.jpg 
/usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/lib/exifr/tiff.rb:573:in `readlong': undefined method `unpack' for nil:NilClass (NoMethodError)
        from /usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/lib/exifr/tiff.rb:460:in `initialize'
        from /usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/lib/exifr/tiff.rb:399:in `new'
        from /usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/lib/exifr/tiff.rb:399:in `initialize'
        from /usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/lib/exifr/tiff.rb:398:in `times'
        from /usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/lib/exifr/tiff.rb:398:in `initialize'
        from /usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/lib/exifr/tiff.rb:448:in `new'
        from /usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/lib/exifr/tiff.rb:448:in `add_field'
        from /usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/lib/exifr/tiff.rb:399:in `initialize'
         ... 14 levels...
        from /usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/bin/exifr:50:in `each'
        from /usr/lib64/ruby/gems/1.8/gems/exifr-1.0.5/bin/exifr:50
        from /usr/bin/exifr:19:in `load'
        from /usr/bin/exifr:19

readlong (and also readshort) try to access data out of range.
self[pos..(pos + 3)] returns nil, so nil.unpack called and NoMethodError thrown.

In my case, I wrote wrapper method and catched all exception from readlong.

I'm using rails, so I put these code in config/environment.rb.

my envrionment: ruby version 1.8.6, exifr version 1.0.5 (newest)

Copy link

kyanny commented Aug 2, 2011

Very quick fix, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
None yet

No branches or pull requests

2 participants