-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Reading stats from 1x1 buffer gives error #2372
Description
My version is 0.26.0
What are the steps to reproduce?
- Take an image and resize it to 1x1
- Try to get stats from it
What is the expected behaviour?
To get stats
Are you able to provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem?
This is the part from my code:
mainPipeline
.clone()
.extract({ top: 0, left: 0, width: widthPixel, height: heightPixel })
.resize(1, 1)
.toBuffer()
.then(buffer => sharp(buffer).stats());
It works fine if I do resize with 2, 2 or 1, 2 or if I remove the resize completely but it doesn't work with 1, 1, it's not the problem with resize though because I was able to output that 1x1 to a file and that worked, only reading stats doesn't work.
I'm doing the resizing because I want to get the average colour of the image and it works better if I resize the image to 1x1 and then read the colours of that pixel than if I read the mean values of each channel.
This is the error in the console:
`(sharp:9156): GLib-GObject-WARNING **: 01:53:38.465: value "nan" of type 'gdouble' is invalid or out of range for property 'out' of type 'gdouble'
(node:9156) UnhandledPromiseRejectionWarning: Error: deviate: parameter out not set
(Use node --trace-warnings ... to show where the warning was created)
(node:9156) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:9156) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.`
What is the output of running npx envinfo --binaries --system?
System:
OS: Windows 10 10.0.19041
CPU: (4) x64 Intel(R) Core(TM) i5-7600K CPU @ 3.80GHz
Memory: 1.81 GB / 15.89 GB
Binaries:
Node: 14.9.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD