sharp
sharp copied to clipboard
"extend" May Fail for Animated TIFF
Possible bug
Is this a possible bug in a feature of sharp, unrelated to installation?
- [x] Running
npm install sharp
completes without error. - [x] Running
node -e "require('sharp')"
completes without error.
Are you using the latest version of sharp?
- [x] I am using the latest version of
sharp
as reported bynpm 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.
Thanks for reporting, commit https://github.com/lovell/sharp/commit/397ee492d922e2bc9c871ae964bfe440f582ce07 fixes this and adds these dimensions as a test case that would previously have failed.
v0.33.4 now available.