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

"extend" May Fail for Animated TIFF #4069

Open
3 tasks done
stefanpieper opened this issue Apr 17, 2024 · 1 comment
Open
3 tasks done

"extend" May Fail for Animated TIFF #4069

stefanpieper opened this issue Apr 17, 2024 · 1 comment

Comments

@stefanpieper
Copy link

Possible bug

Is this a possible bug in a feature of sharp, unrelated to installation?

  • Running npm install sharp completes without error.
  • Running node -e "require('sharp')" completes without error.

Are you using the latest version of sharp?

  • I am using the latest version of sharp as reported by npm view sharp dist-tags.latest.

What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?

  System:
    OS: macOS 14.4.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 42.73 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.19.0 - ~/.nvm/versions/node/v18.19.0/bin/node
    npm: 10.2.3 - ~/.nvm/versions/node/v18.19.0/bin/npm
    pnpm: 8.14.1 - ~/.nvm/versions/node/v18.19.0/bin/pnpm
  npmPackages:
    sharp: ^0.33.3 => 0.33.3 

Same issue is visible in AWS Lambda on x86_64 architecture.

What are the steps to reproduce?

The attached source with the given TIFF file ends up in an error. The relevant code lines are:

buffer = await fs.readFileSync('./animated-12-frames.tiff')
let image = sharp(buffer, { animated: true })
await image.extend({top: 1}).toBuffer()

Explanation: a 12-frame animated TIFF is loaded and extend with one pixel at top is executed.

What is the expected behaviour?

The toBuffer should complete without error.

Actually, an error in libvips occurs:

Error: tiff2vips: out of order read -- at line 1386, but line 1260 requested

With small changes on the code, the error won't show:

  • 6-frame animated TIFF instead of 12-frame
  • extending by 8 pixel instead of 1
  • extending with repeat instead of default

These successful variations are given in attached sample code as well.

I am unsure whether this might be a SharpJS issue or rather one in libvips. But it shows that how libvips is called makes a difference (extendWith: "repeat" which, to my understanding, enforces sequential operation).

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem

animated-tiff-extend-issue.zip

Please provide sample image(s) that help explain this problem

See archive above.

@lovell
Copy link
Owner

lovell commented Apr 18, 2024

Thanks for reporting, commit 397ee49 fixes this and adds these dimensions as a test case that would previously have failed.

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

No branches or pull requests

2 participants