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
Call .trim() on an image that is pure black. This error is thrown:
Error: Unexpected error while trimming. Try to lower the tolerance
What is the expected behaviour?
out.png is created. Since it's all black I'm not sure if trim should noop here or create an empty image. We call trim() on images uploaded by users, where we don't know beforehand if they can be trimmed or not. If .trim() behaves correctly here, do you know of a way to find out if an image can't be trimmed beforehand?
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
it's all black I'm not sure if trim should noop here or create an empty image.
Hi, yes, the key question is what happens when using trim() with an image where all pixels have the same value, including the alpha channel. Is this an error, the current behaviour, or a no-op as proposed? I do like your suggestion as it should improve the user experience.
This is somewhat related to #2166, which I think that should be implemented first, before altering the default nothing-to-trim behaviour.
Let's mark this as an enhancement. Happy to accept a PR for #2166 and/or this issue, if you're able.
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?
Call
.trim()
on an image that is pure black. This error is thrown:What is the expected behaviour?
out.png
is created. Since it's all black I'm not sure if trim should noop here or create an empty image. We calltrim()
on images uploaded by users, where we don't know beforehand if they can be trimmed or not. If.trim()
behaves correctly here, do you know of a way to find out if an image can't be trimmed beforehand?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: