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

Some files cause "Offset is outside the bounds" error #31

Closed
til-schneider opened this issue Jun 18, 2020 · 4 comments
Closed

Some files cause "Offset is outside the bounds" error #31

til-schneider opened this issue Jun 18, 2020 · 4 comments

Comments

@til-schneider
Copy link
Contributor

I recently added exifr to Picturama. It made the photo import 20x faster! Thank you very much for that.

However in my tests I discovered that some images fail to scan with an "Offset is outside the bounds" error. The old lib I used before (exif-parser) was able to scan these images.

Here is an example image: https://github.com/picturama/test-data/raw/master/photos/800/door-knocker.jpg

Test call (tested with exifr 5.0.2):

// Works
await exifr.parse(imagePath)

// Fails
await exifr.parse(imagePath, { xmp: true })

Here is the stack:

Error: Offset is outside the bounds of the DataView RangeError: Offset is outside the bounds of the DataView
      at DataView.getUint16 (<anonymous>)
      at Object.getUint16 (node_modules/exifr/dist/full.umd.js:1:3497)
      at Object._findAppSegments (node_modules/exifr/dist/full.umd.js:1:22124)
      at Object.findAppSegments (node_modules/exifr/dist/full.umd.js:1:21174)
      at Object.parse (node_modules/exifr/dist/full.umd.js:1:20428)
      at ee.parse (node_modules/exifr/dist/full.umd.js:1:12339)
      at Object.te [as parse] (node_modules/exifr/dist/full.umd.js:1:13138)

However when I try this image on your homepage then in works - even with xmp enabled. Are you using an older version of exifr there?

@MikeKovarik
Copy link
Owner

Hello. Firstly: Glad you use and like it. :)

I quickly looked into it before work and found what causes it.
So exifr by default reads files by chunks. This makes it that fast - quickly gauge if it's worth to keep parsing the file or quit early.

Why website works? Chunk reading is a heuristic. It works on 99% of files. But there's still that 1% (which is malformed or non standard anyway). Exifr doesn't crash in this case. It just may not reach all the metadata. So i disabled chunked reader in the website.

What cause your problem is a bug where the metadata header was split, right around the edge of the loaded chunk.

I will try to release the fix when i get home from work. Or maybe tomorrow since I've done some unfinished and uncommited work that needs to be cleaned first.

For now, you can disable chunk reading with options {chunked: false}

@vip30
Copy link
Contributor

vip30 commented Jul 24, 2020

I just starting switch project from iptc library to exifr, it works quite well to be honest.

However, I have couple of images have these problems:

  • When I enable iptc, it throws RangeError: Offset is outside the bounds of the DataView
  • and another image when enable icc, it throws RangeError: Invalid typed array length: -6

Even in the homepage still got the errors:

image

image

Images:
a.jpg
b.jpg

@MikeKovarik
Copy link
Owner

Hello. Thank you both for the info and problematic files 👍. I just released 5.0.3 which fixes all of your bugs.

@til-schneider
Copy link
Contributor Author

Thank you very much for the fix. It is included in the new version 1.2.0 of Picturama. 👍

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

No branches or pull requests

3 participants