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

Regression in v0.31.3: linear filter is not applied correctly to 16-bit images #3605

Closed
3 tasks done
SaraKaminska opened this issue Mar 29, 2023 · 4 comments
Closed
3 tasks done

Comments

@SaraKaminska
Copy link

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: Windows 10 10.0.19044
CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
Memory: 4.98 GB / 15.75 GB
Binaries:
Node: 19.6.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
npm: 9.4.0 - C:\Program Files\nodejs\npm.CMD
npmPackages:
sharp: ^0.32.0 => 0.32.0

What are the steps to reproduce?

  1. Read a 16-bit PNG image with Sharp.
  2. Apply the linear filter with any custom value.
  3. Apply toColorspace('grey16') to ensure the space is maintained.
  4. Save the image to file.

What is the expected behavior?

The expected behavior is that the linear filter is applied to the image with the expected result. Instead the output image is completely black. This issue occurred in the version 0.31.3. My guess is that the reson for this issue is setting the option to "uchar" when applying linear.
See src/operations.cc row 148:
return RemoveAlpha(image).linear(a, b, VImage::option()->set("uchar", TRUE)).bandjoin(alpha);

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

const sharp = require("sharp");

const adjusted = sharp('16-bit.png')
  .linear(1.1, 10)
  .toColorspace('grey16')
  .toFile('gamma-16-bit.png')

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

Original
16-bit

Output
linear-16-bit

@lovell lovell added bug and removed triage labels Mar 29, 2023
@lovell
Copy link
Owner

lovell commented Mar 29, 2023

Thanks for reporting this, you're quite right about the uchar in there that's causing it.

This was a regression caused by #3468 in v0.31.3 so you might be able to workaround this by pinning to v0.31.2.

@lovell lovell added this to the v0.32.1 milestone Mar 29, 2023
@lovell lovell changed the title The linear filter is not applied correctly to 16-bit images Regression in v0.31.3: linear filter is not applied correctly to 16-bit images Mar 29, 2023
@SaraKaminska
Copy link
Author

Thank you for the fast answer. Yes, will continue working on an older version until this bug is fixed.

@lovell
Copy link
Owner

lovell commented Apr 1, 2023

Commit b9c3851 fixes this and adds a test that would previously have failed to help prevent regression. This will be in v0.32.1.

@lovell
Copy link
Owner

lovell commented Apr 27, 2023

v0.32.1 now available.

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