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

Setting WebP effort to 0 in constructor does not change the object's effort option to 0 #3259

Closed
AlexanderTheGrey opened this issue Jun 13, 2022 · 4 comments

Comments

@AlexanderTheGrey
Copy link
Contributor

Possible bug

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

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

  • [ X] 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: macOS 10.15.7
CPU: (6) x64 Intel(R) Core(TM) i5-8500B CPU @ 3.00GHz
Memory: 16.41 MB / 16.00 GB
Shell: 5.7.1 - /bin/zsh
Binaries:
Node: 16.14.2 - ~/.nvm/versions/node/v16.14.2/bin/node
npm: 8.5.0 - ~/.nvm/versions/node/v16.14.2/bin/npm
npmPackages:
sharp: ^0.30.6 => 0.30.6

What are the steps to reproduce?

Setting WebP effort to 0 (fastest) in the constructor does not change the effort option to 0.

However, setting WebP effort 1 in the constructor correctly changes the effort option to 1.

https://sharp.pixelplumbing.com/api-output#webp

What is the expected behaviour?

The effort option should be set to 0.

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

const image = sharp(input.gif, { animated: true }).webp({ quality: 100, effort: 0 })

image.toFile(output.webp, (err) => {
    console.log("WebP Effort ====>", image.options.webpEffort);
    if (err === null) {
      console.log("Success");
    } else {
      console.log("Error")
    }
  });

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

https://en.wikipedia.org/wiki/GIF#/media/File:Rotating_earth_(large).gif

@lovell
Copy link
Owner

lovell commented Jun 14, 2022

Good spot, the problem is here:

const effort = options.effort || options.reductionEffort;

Happy to accept a PR to fix this, if you're able.

@lovell lovell added bug and removed triage labels Jun 14, 2022
@AlexanderTheGrey
Copy link
Contributor Author

Sure, I can do that.

AlexanderTheGrey added a commit to AlexanderTheGrey/sharp that referenced this issue Jun 14, 2022
Setting WebP effort to 0 in the constructor caused the effort to use the
default value of 4.
AlexanderTheGrey added a commit to AlexanderTheGrey/sharp that referenced this issue Jun 15, 2022
Setting WebP effort to 0 in the constructor caused effort to use the
default value of 4.
AlexanderTheGrey added a commit to AlexanderTheGrey/sharp that referenced this issue Jun 15, 2022
Setting WebP effort to 0 in the constructor caused effort to use the
default value of 4.
@lovell lovell added this to the v0.30.7 milestone Jun 17, 2022
@lovell
Copy link
Owner

lovell commented Jun 22, 2022

v0.30.7 now available, thank you for both reporting and fixing this.

@lovell lovell closed this as completed Jun 22, 2022
@AlexanderTheGrey
Copy link
Contributor Author

Thank you for making great open source software!

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