-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
toBuffer()
returns info instead of data, when called after toFile()
#3044
Comments
Hi, this looks like single input multiple output, which suggests that you might want to https://sharp.pixelplumbing.com/api-constructor#clone - await sharpHead.toFile("test.png"); // works as expected
+ await sharpHead.clone().toFile("test.png"); // works as expected Having said that, given there is no Stream based I/O here, we should be able to make an underlying improvement to sharp so the use of file and Buffer based output on the same instance can occur without a need to clone; I'll have a think about this. |
Thanks @lovell for the fast response. I actually do not need single input multiple output mechanisms in my production code. I encountered this problem whilst testing my code. I initially used
Not needing to clone would be the way to go if you ask me, but I don't know if it's possible from a technical point of view. Otherwise an error message would have been really nice and - although I don't know if this is possible - the typescript type definitions should be adjusted, as typescript still assumes that the return value is of type |
Commit 4246602 adds this scenario as a test case, plus the fix. This will be in v0.30.1, thanks for reporting. |
Sounds great, always glad to help, even though I don't have the time to dive into the codebase myself :) Thanks for the timely fix |
v0.30.1 now available. |
Are you using the latest version? Is the version currently in use as reported by
npm ls sharp
the same as the latest version as reported bynpm view sharp dist-tags.latest
?Yes,
0.29.3
.What are the steps to reproduce?
What is the expected behaviour?
Either of two options:
data
as expected instead of theinfo
object.Are you able to provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem?
If you explicitly force sharp to output the
info
object,data
still returnsinfo
andinfo
isundefined
in this case.Are you able to provide a sample image that helps explain the problem?
From my understanding this happens with every image, therefore not applicable.
What is the output of running
npx envinfo --binaries --system
?The text was updated successfully, but these errors were encountered: