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
.trim() removes 1 too many pixels #4084
Comments
You've not provided an example image but the https://sharp.pixelplumbing.com/api-resize#trim .trim({ lineArt: true }) |
My image was a PNG of some document with typed text. What is the impact on performance of |
I would expect minimal, it might be very slightly faster, you'll need to profile using samples of the type of image you're likely to have to process.
You'll need to determine which setting is most appropriate for the type of image you're likely to have to process. |
Thank you for the answer, however, I am still confused about this setting. Could you explain a bit more what the Docs description:
Maybe... What does this even really mean? |
If the input is best represented as in a vector format such as SVG or uses a lossless compression such as PNG then If the input is more photographic and/or uses a lossy format such as JPEG then some smoothing of the noise is required to ensure The underlying libvips operation is vips_find_trim. |
Possible bug:
.trim()
removes 1 pixel too manyWhen using
.trim()
Sharp.js will remove 1 too many pixels. I first noticed it in the metadata returned by.trim()
:trimOffsetLeft
andtrimOffsetTop
.I also confirmed it is not just an error in the data returned, by testing it on a PNG.
Instead of only removing the border up-to (and excluding) the first pixel of color change, it also removes that first pixel of different color.
I noticed this difference, as I am porting from ImageMagick to Sharp.js. (ImageMagick willl remove the correct amount: only up-to the first changed pixel.)
Possible fix: Make
.trim()
remove all the border only up-to the new color.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.Are you using the latest version of sharp?
sharp
as reported bynpm view sharp dist-tags.latest
.The text was updated successfully, but these errors were encountered: