Skip to content

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

@Granga

Description

@Granga

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions