Skip to content

Trimming b-w images do not work after upgrade to 0.31.0 #3386

@marcincichocki

Description

@marcincichocki

Possible bug

Is this a possible bug in a feature of sharp, unrelated to installation?

  • Running npm install sharp completes without error.
  • Running 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?

  • I am using the latest version of sharp as reported by npm 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?

  System:
    OS: Linux 4.19 Ubuntu 20.04 LTS (Focal Fossa)
    CPU: (6) x64 Intel(R) Core(TM) i5-8600K CPU @ 3.60GHz
    Memory: 10.27 GB / 12.45 GB
    Container: Yes
    Shell: 5.8 - /usr/bin/zsh
  Binaries:
    Node: 14.17.1 - ~/.nvm/versions/node/v14.17.1/bin/node
    npm: 7.18.1 - ~/.nvm/versions/node/v14.17.1/bin/npm
  npmPackages:
    sharp: ^0.31.0 => 0.31.0

What are the steps to reproduce?

Run code sample in node.js against provided image. It is correctly trimmed in 0.30.7, but not in 0.31.0. Interestingly, when trimming
sharp(await instance.toBuffer()) trimming works as expected.

What is the expected behaviour?

Test image should be trimmed just like on 0.30.7

Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem

const sharp = require('sharp');

(async () => {
  const instance = sharp('./test.png');
  const meta = await instance.metadata();

  console.log(meta);

  const { data, info } = await instance
    .trim()
    .toBuffer({ resolveWithObject: true });

  console.log(info); // trimOffsetLeft is 0
  console.log(data.toString('base64'));
})();

Please provide sample image(s) that help explain this problem

test2

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions