Repository navigation
Description
Possible bug
Is this a possible bug in a feature of sharp, unrelated to installation?
- Running
npm install sharpcompletes without error. - Running
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?
- I am using the latest version of
sharpas 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?
System:
OS: macOS 15.1
CPU: (8) arm64 Apple M2
Memory: 81.58 MB / 24.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 22.18.0 - /Users/kleinke/.nvm/versions/node/v22.18.0/bin/node
npm: 10.9.3 - /Users/kleinke/.nvm/versions/node/v22.18.0/bin/npm
npmPackages:
sharp: 0.34.4 => 0.34.4
Does this problem relate to file caching?
The default behaviour of libvips is to cache input files, which can lead to EBUSY or EPERM errors on Windows.
Use sharp.cache(false) to switch this feature off.
- Adding
sharp.cache(false)does not fix this problem.
Does this problem relate to images appearing to have been rotated by 90 degrees?
Images that contain EXIF Orientation metadata are not auto-oriented. By default, EXIF metadata is removed.
-
To auto-orient pixel values use the parameter-less
rotate()operation. -
To retain EXIF Orientation use
keepExif(). -
Using
rotate()orkeepExif()does not fix this problem.
What are the steps to reproduce?
The error occurs when calling toBuffer for a GeoTiff file. It occurred for all GeoTiff files i tried, while all other tiff files worked, so I assume that GeoTiff is the problem here.
What is the expected behaviour?
Until sharp 0.34.2, we could use sharp to create resized JPG variants of GeoTiff files. With 0.34.3 und 0.34.4, the error "Unknown error" is thrown when calling toBuffer. We run sharp in Electron, but the error also occurs when running the code below in a node script outside of Electron. I tested it on macOS 15.1 and on Windows 11.
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
Download this GeoTiff sample file from osgeo and run this code:
const sharp = require('sharp');
sharp('cea.tif').toBuffer();
Please provide sample image(s) that help explain this problem
See above.
Activity
lovell commentedon Oct 15, 2025
If you set the
NODE_DEBUG=sharpenvironment variable you'll see this image generates lots of warnings:If you trust the source of your input(s) and would like to ignore these warnings, use
failOn:https://sharp.pixelplumbing.com/api-constructor/
v0.34.3 introduced upstream improvements to warning/error handling in libtiff and libvips, which have now exposed this image as one that should previously have been failing to load.
https://sharp.pixelplumbing.com/changelog/v0.34.3/
tkleinke commentedon Oct 16, 2025
Hi @lovell, thanks for your fast and very helpful reply! Using failOn works and solves my problem for now, so I can switch back to the latest sharp version.
However, the tags listed as warnings are all tags of the GeoTIFF standard, which means that sharp fails right now for all GeoTIFF images if run with the default settings. I think it would be better to ignore warnings for these tags completely (or give an option to do that).
lovell commentedon Oct 16, 2025
Please see libvips/libvips#2377
tkleinke commentedon Oct 16, 2025
I see that it's a bigger problem than I thought (here's a discussion about this as well: libvips/libvips#3996). Ignoring the warnings with failOn seems to be the best approach then. I'm closing this issue, thanks again for your assistance.
neave commentedon Oct 17, 2025
I'm having the same problem when processing lots of GeoTIFFs. It's unfortunate that the only workaround seems to be to be set
failOn: 'error'to every single call. Ideally sharp would not break when an image has GeoTIFF tags, like it used to do. PerhapsfailOn: 'error'could become the default, so we can setfailOn: 'warning'when we want it to fail. Or even have a global setting in sharp.lovell commentedon Oct 17, 2025
It used to let through potentially invalid/corrupt TIFF images, whereas the current version now matches the documented default behaviour of safely failing on warnings. GeoTIFF images are not really supported by libvips (or libtiff for that matter), hence the warnings.
What I would like to do is investigate what might be possible to improve the "Unknown error" messaging as that's not very helpful on its own.
[-]Unknown error when calling toBuffer for GeoTiff file since 0.34.3[/-][+]Enhancement: improve warning/error messages from GeoTiff images (currently reports "Unknown error")[/+]neave commentedon Oct 17, 2025
@lovell Yes, that would be much better as I had to a little digging to find this problem at first. Maybe it could relay the "Unknown field with tag" message, or suggest to use
failOn: 'error'to suppress the warning. Thank you!Improve error messaging when only warnings issued #4465
lovell commentedon Oct 17, 2025
Commit c1c16ed helps prevent the "Unknown error" message and will be part of v0.34.5.
lovell commentedon Nov 6, 2025
v0.34.5 now available.
chore(deps): update dependency sharp to ^0.35.5 (#9)