Skip to content

Commit

Permalink
Allow WebP encoding effort of 0 (#3261)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderTheGrey authored Jun 17, 2022
1 parent b10d8f8 commit 4662527
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/output.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ function webp (options) {
if (is.defined(options.smartSubsample)) {
this._setBooleanOption('webpSmartSubsample', options.smartSubsample);
}
const effort = options.effort || options.reductionEffort;
const effort = is.defined(options.effort) ? options.effort : options.reductionEffort;
if (is.defined(effort)) {
if (is.integer(effort) && is.inRange(effort, 0, 6)) {
this.options.webpEffort = effort;
Expand Down
6 changes: 6 additions & 0 deletions test/unit/webp.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,12 @@ describe('WebP', function () {
});
});

it('should set effort to 0', () => {
const effort = sharp().webp({ effort: 0 }).options.webpEffort;

assert.strictEqual(effort, 0);
});

it('invalid loop throws', () => {
assert.throws(() => {
sharp().webp({ loop: -1 });
Expand Down

0 comments on commit 4662527

Please sign in to comment.