question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trim functionality fails with error: Unexpected error while trimming. Try to lower the tolerance

See original GitHub issue

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:

async trim(dataUrl: string) {
    dataUrl = dataUrl.replace(/^data:image\/png;base64,/, "");
    dataUrl += dataUrl.replace('+', ' ');

    let buffer = new Buffer(dataUrl, "base64");

    return sharp(buffer)
        .png()
        .trim(1) //also tried default parameter
        .toBuffer();
}

This is the output in console: Error: Unexpected error while trimming. Try to lower the tolerance.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

3reactions
lovellcommented, Nov 17, 2019

v0.23.3 now available, thank you for the original report.

1reaction
lovellcommented, Mar 18, 2019

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cutting contour is outside of the supporting geometry. No ...
Unexpected error while reading the file. Graphics are not updated with the source file, the original shape graphics are retained. Correct the file....
Read more >
Fixed Problem Reports - Siemens PLM
Internal error followed by NX crash during undo redo while checking requirement. 8365439. Styled Blend tolerance problem with activated Trimming Method Trim ......
Read more >
When the Solver Fails - MATLAB & Simulink - MathWorks
The solver stopped because it reached a limit on the number of iterations or function evaluations before it minimized the objective to the...
Read more >
User guide — Cutadapt 4.2 documentation - Read the Docs
All the above sequences are trimmed to mysequence when you use -g ADAPTER . ... if you search for the adapter sequence ADAPTER...
Read more >
Next Step When Boolean Cut Operations Fail?
Solution ¨C either try to move the seam, or try moving one object just a tiny, tiny bit (if you can without making...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found