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

Getting AssertionError when trying to get orientation of certain image #94

Open
ilyai opened this issue Nov 14, 2022 · 1 comment
Open
Assignees
Labels
bug Something isn't working

Comments

@ilyai
Copy link

ilyai commented Nov 14, 2022

It works fine for most of the images, but I've found an image which get-orientation fails to process. The error message is the following:

node:assert:399
    throw err;
    ^

AssertionError [ERR_ASSERTION]: can only skip > 0 bytes, got "-4"
    at EXIFOrientationParser._skipBytes (/Users/iig/IdeaProjects/fugo-media-processor/node_modules/stream-parser/index.js:117:3)
    at EXIFOrientationParser.<anonymous> (/Users/iig/IdeaProjects/fugo-media-processor/node_modules/get-orientation/index.js:48:26)
    at process (/Users/iig/IdeaProjects/fugo-media-processor/node_modules/stream-parser/index.js:270:20)
    at /Users/iig/IdeaProjects/fugo-media-processor/node_modules/stream-parser/index.js:204:14
    at /Users/iig/IdeaProjects/fugo-media-processor/node_modules/stream-parser/index.js:294:16
    at EXIFOrientationParser.write [as _write] (/Users/iig/IdeaProjects/fugo-media-processor/node_modules/stream-parser/index.js:157:3)
    at writeOrBuffer (node:internal/streams/writable:389:12)
    at _write (node:internal/streams/writable:330:10)
    at EXIFOrientationParser.Writable.write (node:internal/streams/writable:334:10)
    at ReadStream.ondata (node:internal/streams/readable:754:22) {
  generatedMessage: false,
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '=='
}

Here is the image which makes get-orientation to fail:

lookupstrata_logo

I'm using the latest version of the package: 1.1.2

@mooyoul mooyoul added the bug Something isn't working label Nov 14, 2022
@mooyoul
Copy link
Owner

mooyoul commented Nov 14, 2022

Hello there! Thank you for reporting.

Just checked the image and noticed that image contains "empty" non-EXIF APP1 marker which expressed to 2 bytes segment length. Currently parser assumes APP1 segment length to be greater or equal than 8 bytes for non-EXIF APP1 segment to skip unnecessary bytes, but that 2 bytes segment length made parser to skip negative bytes (-6 bytes). So this resulted to that error.

I thought that I've tested get-orientation with many "corrupted" JPEG images, but wow. your case is not covered by that test images.
I can fix this issue and I will include this image to "corrupted" image set for testing. but hey, Can I use this image for testing? I have concerns about image licensing.

Unfortunately, I cannot guarantee an ETA at this moment but expected to be resolved in next 2 weeks - I've been super busy recent days and I don't have enough spare time to fix this issue 😭

Anyway thanks again for reporting this and this was super helpful for me. Stay tuned!

  • Sending ❤️ from Seoul

@mooyoul mooyoul self-assigned this Nov 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants