Closed jkh19 closed 1 year ago
Yes, this PNG is corrupt. If present, an EXIF chunk has to be at least 4 bytes (to determine endianness) but this image defines a zero-length chunk. It's much safer for a decoder to bail out at this point rather than try to keep going.
Chunk: Data Length 0 (max 2147483647), Type 1716082789 [eXIf]
It might be worth creating a new issue for this specific image upstream at https://github.com/randy408/libspng and link it to https://github.com/randy408/libspng/issues/14 as it may fall under into the category of conformance vs compatibility.
Upstream issue at https://github.com/randy408/libspng/issues/247
@lovell - With the upstream issue addressed, would it be possible to please include this new version of libspng in a future release?
I am just trying to weigh the option of investigating workarounds in the meantime.
Thanks!
@randy408 Thank you!
@jkh19 Yes. If taking advantage of the upstream fix is urgent for you, please remember that sharp will always look for and use a globally-installed libvips (and its dependencies) if available, so you may want to consider that route.
@lovell Thanks for the response.
Please forgive my ignorance, but I have been kind of floundering with your recommendation (which I have been trying to pursue as it is becoming a more pressing issue for my needs).
From my understanding, Sharp uses libvips, which uses libspng. So if I get my environment updated with the latest libspng, would it end up getting picked up by libvips (and in turn Sharp)?
I am running this inside an AWS Lambda function, but I have generally been unsuccessful in trying to even get the latest libspng available in a standalone environment (since it at least doesn't seem to be available as a package to install via apt-get or npm, and attempts to build via meson or cmake seem to require later versions than I have available in my Ubuntu running on WSL).
Any insight on the best approach to getting this globally-installed libvips option in place would be greatly appreciated (or a 0.33.0 release 😄 ...unless that ends up being dependent on libvips being updated first).
@jkh19 For Lambda, perhaps look at using a layer e.g. something based on https://github.com/zoellner/sharp-heic-lambda-layer however waiting may be easier.
@lovell Great, thanks - I did consider that it could end up being a lambda layer, but I was struggling with the equivalent commands that would get libspng installed and available (I assume it'd be similar to the Makefile in the repo you linked, where it grabs the latest .tar.gz file, and then uses cmake or meson based on the libspng docs?).
Do you have any guess on the 0.33.0 release timing?
In the mean time, I'll take a look at the layer approach so thanks for the tip.
The prebuilt binaries provided by sharp v0.32.4 include libspng v0.7.4, thanks all for reporting/fixing.
Possible bug
Is this a possible bug in a feature of sharp, unrelated to installation?
npm install sharp
completes without error.node -e "require('sharp')"
completes without error.If you cannot confirm both of these, please open an installation issue instead.
Are you using the latest version of sharp?
sharp
as reported bynpm view sharp dist-tags.latest
.If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.
If you are using another package which depends on a version of
sharp
that is not the latest, please open an issue against that package instead.What is the output of running
npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp
?What are the steps to reproduce?
When attempting to use certain PNG images in various operations (e.g., retrieve metadata, resize), the following error is received:
Error: Input file has corrupt header: pngload: reached chunk/cache limits
I came across an issue with a similar error message, but setting the
unlimited
option flag totrue
does not seem to have any impact.What is the expected behaviour?
The associated operation (retrieve metadata, resize) should succeed with these images, unless there is something inherently wrong with these files, though I have encountered this issue with over 100 files thus far.
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
Running
node .\testPng.js
with the following results inAn error occurred during processing: Error: Input file has corrupt header: pngload: reached chunk/cache limits
. Note thatgithub.png
is provided below as part of this issue.testPng.js:
Please provide sample image(s) that help explain this problem
github.png:
Additional analysis of png file
Note the warning about too short eXIf data in the last line of the
identify
output, if that is suspect?