-
-
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
Trim functionality fails with error: Unexpected error while trimming. Try to lower the tolerance #1597
Comments
Hello, the following entry for v0.21.0 in the changelog is relevant here:
Please can you provide a sample image that behaves in this manner. |
Thank you for your response @lovell. Both 'jpeg' and 'png' produce this error. Here's the png that won't trim: |
My node version is v10.15.1 on Windows10. I did another test with the uploaded png: |
Then we just need a way to automate mspaint :) |
@Granga Thank you for the example PNG. I think this has something to do with the input being 2 channel greyscale+alpha but I'll need to take a closer look. |
All of the pixels in this image are black and the text is contained only in the transparency layer. By default sharp/libvips flattens to black hence the entire image is background. We need to retrieve the background colour from the bKGD chunk in the PNG, if present, and flatten to that instead. |
Hi, |
Why you don't add vips_find_trim as sharp function to just get the information I need to execute this on fully transparent picture to get right coordinates
With current implementation it's impossible. |
An alternative approach would be to modify libvips to optionally include the alpha channel in the calculation. |
Commit c41b873 adds this test case and the code change to handle it, which is to fallback to using the alpha channel to determine "boringness" if the initial search of the non-alpha channels fails. |
v0.23.3 now available, thank you for the original report. |
In the latest version 0.21.3, trimming a png image fails.
In a previous version 0.20.8, the code completes successfully.
Here's my function in typescript:
This is the output in console:
Error: Unexpected error while trimming. Try to lower the tolerance
.The text was updated successfully, but these errors were encountered: