Remove previously-deprecated reductionEffort and speed options

This commit is contained in:
Lovell Fuller 2022-07-24 11:18:16 +01:00
parent b46ab510da
commit 76c4c51e2a
4 changed files with 7 additions and 33 deletions

View File

@ -12,6 +12,8 @@ Requires libvips v8.13.0
* Add WebP `minSize` and `mixed` options for greater control over animation frames. * Add WebP `minSize` and `mixed` options for greater control over animation frames.
* Remove previously-deprecated WebP `reductionEffort` and HEIF `speed` options. Use `effort` to control these.
* Use combined bounding box of alpha and non-alpha channels for `trim` operation. * Use combined bounding box of alpha and non-alpha channels for `trim` operation.
[#2166](https://github.com/lovell/sharp/issues/2166) [#2166](https://github.com/lovell/sharp/issues/2166)

View File

@ -500,12 +500,11 @@ function webp (options) {
if (is.defined(options.smartSubsample)) { if (is.defined(options.smartSubsample)) {
this._setBooleanOption('webpSmartSubsample', options.smartSubsample); this._setBooleanOption('webpSmartSubsample', options.smartSubsample);
} }
const effort = is.defined(options.effort) ? options.effort : options.reductionEffort; if (is.defined(options.effort)) {
if (is.defined(effort)) { if (is.integer(options.effort) && is.inRange(options.effort, 0, 6)) {
if (is.integer(effort) && is.inRange(effort, 0, 6)) { this.options.webpEffort = options.effort;
this.options.webpEffort = effort;
} else { } else {
throw is.invalidParameterError('effort', 'integer between 0 and 6', effort); throw is.invalidParameterError('effort', 'integer between 0 and 6', options.effort);
} }
} }
if (is.defined(options.minSize)) { if (is.defined(options.minSize)) {
@ -884,12 +883,6 @@ function heif (options) {
} else { } else {
throw is.invalidParameterError('effort', 'integer between 0 and 9', options.effort); throw is.invalidParameterError('effort', 'integer between 0 and 9', options.effort);
} }
} else if (is.defined(options.speed)) {
if (is.integer(options.speed) && is.inRange(options.speed, 0, 9)) {
this.options.heifEffort = 9 - options.speed;
} else {
throw is.invalidParameterError('speed', 'integer between 0 and 9', options.speed);
}
} }
if (is.defined(options.chromaSubsampling)) { if (is.defined(options.chromaSubsampling)) {
if (is.string(options.chromaSubsampling) && is.inArray(options.chromaSubsampling, ['4:2:0', '4:4:4'])) { if (is.string(options.chromaSubsampling) && is.inArray(options.chromaSubsampling, ['4:2:0', '4:4:4'])) {

View File

@ -52,7 +52,7 @@ describe('HEIF', () => {
}); });
it('valid effort does not throw an error', () => { it('valid effort does not throw an error', () => {
assert.doesNotThrow(() => { assert.doesNotThrow(() => {
sharp().heif({ speed: 6 }); sharp().heif({ effort: 6 });
}); });
}); });
it('out of range effort should throw an error', () => { it('out of range effort should throw an error', () => {
@ -65,21 +65,6 @@ describe('HEIF', () => {
sharp().heif({ effort: 'fail' }); sharp().heif({ effort: 'fail' });
}); });
}); });
it('valid speed does not throw an error', () => {
assert.doesNotThrow(() => {
sharp().heif({ speed: 6 });
});
});
it('out of range speed should throw an error', () => {
assert.throws(() => {
sharp().heif({ speed: 10 });
});
});
it('invalid speed should throw an error', () => {
assert.throws(() => {
sharp().heif({ speed: 'fail' });
});
});
it('invalid chromaSubsampling should throw an error', () => { it('invalid chromaSubsampling should throw an error', () => {
assert.throws(() => { assert.throws(() => {
sharp().heif({ chromaSubsampling: 'fail' }); sharp().heif({ chromaSubsampling: 'fail' });

View File

@ -121,12 +121,6 @@ describe('WebP', function () {
}); });
}); });
it('invalid reductionEffort (deprecated) throws', () => {
assert.throws(() => {
sharp().webp({ reductionEffort: true });
});
});
it('out of range effort throws', () => { it('out of range effort throws', () => {
assert.throws(() => { assert.throws(() => {
sharp().webp({ effort: -1 }); sharp().webp({ effort: -1 });