You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Using rotate() or keepExif() does not fix this problem.
What are the steps to reproduce?
Create an empty image file touch test.jpg
Try reading it, e.g. by doing sharp('test.jpg').toBuffer();
File extension doesn't matter, I've tried *.avif, *.png, etc.
Result:
> node index.js
/Users/dmitry/Projects/sharp-empty-image/node_modules/sharp/lib/output.js:163
const stack = Error();
^
Error: Input file contains unsupported image format
at Sharp.toBuffer (/Users/dmitry/Projects/sharp-empty-image/node_modules/sharp/lib/output.js:163:17)
at Object.<anonymous> (/Users/dmitry/Projects/sharp-empty-image/index.js:3:19)
at Module._compile (node:internal/modules/cjs/loader:1546:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1691:10)
at Module.load (node:internal/modules/cjs/loader:1317:32)
at Module._load (node:internal/modules/cjs/loader:1127:12)
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:166:5)
at node:internal/main/run_main_module:30:49
What is the expected behaviour?
Some kind of error which explicitly tells that the file is empty.
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
constsharp=require('sharp');// test.jpg must exists and be emptysharp('test.jpg').toBuffer();
Please provide sample image(s) that help explain this problem
The text was updated successfully, but these errors were encountered:
This is something that would need to be addressed in the upstream libvips dependency as it currently does not differentiate between empty and non-empty files.
$ touch empty.jpg
$ echo "fail" >not-empty.jpg
$ vipsheader empty.jpg
vipsheader: VipsForeignLoad: "empty.jpg" is not a known file format
$ vipsheader not-empty.jpg
vipsheader: VipsForeignLoad: "not-empty.jpg" is not a known file format
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
?Does this problem relate to file caching?
The default behaviour of libvips is to cache input files, which can lead to
EBUSY
orEPERM
errors on Windows.Use
sharp.cache(false)
to switch this feature off.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?
touch test.jpg
sharp('test.jpg').toBuffer();
File extension doesn't matter, I've tried
*.avif
,*.png
, etc.Result:
What is the expected behaviour?
Some kind of error which explicitly tells that the file is empty.
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
Please provide sample image(s) that help explain this problem
The text was updated successfully, but these errors were encountered: