Skip to content

Operation "linear" does not work with uncompressed TIFF #3468

@stefanpieper

Description

@stefanpieper

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.

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.

What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?

  System:
    OS: macOS 12.6.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 3.44 GB / 32.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
  npmPackages:
    sharp: ^0.31.2 => 0.31.2 

What are the steps to reproduce?

When doing a conversion to uncompressed tiff and "linear" in the same pipeline, the resulting image is not as expected.

What is the expected behaviour?

The image should be output by the sample code below "as is" (linear(1, 0) being an idempotent operation). This works well with other formats than uncompressed TIFF.

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

  let buffer = await fs.readFileSync(path.join(__dirname, "resources/images/random-small.jpeg"));
  buffer = await sharp(buffer)
    .tiff({compression: 'none'})
    .linear(1, 0)
    .toBuffer();
  await sharp(buffer)
    .jpeg()
    .toFile(path.join(__dirname, "resources/transformed/linear-fail.jpeg"));

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

This is my test image that I would expect to remain basically unchanged in output with the code above:

random-small

This is what the code actually produces (the image is nearly all-white and can therefore hardly be seen):

linear-fail

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions