Skip to content
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

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

Closed
3 tasks done
stefanpieper opened this issue Nov 24, 2022 · 3 comments
Closed
3 tasks done

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

stefanpieper opened this issue Nov 24, 2022 · 3 comments

Comments

@stefanpieper
Copy link

stefanpieper commented Nov 24, 2022

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

@lovell
Copy link
Owner

lovell commented Dec 4, 2022

Thanks for reporting, commit 0265d30 ensures the output is integral rather than float, plus adds a couple of tests that would have caught this.

@lovell lovell added this to the v0.31.3 milestone Dec 4, 2022
@stefanpieper
Copy link
Author

Beautiful - thanks a lot!

@lovell
Copy link
Owner

lovell commented Dec 21, 2022

v0.31.3 now available, thanks again for reporting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants