Add mixed and minSize animation options for WebP output

This commit is contained in:
Lovell Fuller
2022-07-12 14:51:03 +01:00
parent 1b84ccbbe9
commit d247c02762
8 changed files with 49 additions and 1 deletions

View File

@@ -469,6 +469,8 @@ function png (options) {
* @param {number} [options.effort=4] - CPU effort, between 0 (fastest) and 6 (slowest)
* @param {number} [options.loop=0] - number of animation iterations, use 0 for infinite animation
* @param {number|number[]} [options.delay] - delay(s) between animation frames (in milliseconds)
* @param {boolean} [options.minSize=false] - prevent use of animation key frames to minimise file size (slow)
* @param {boolean} [options.mixed=false] - allow mixture of lossy and lossless animation frames (slow)
* @param {boolean} [options.force=true] - force WebP output, otherwise attempt to use input format
* @returns {Sharp}
* @throws {Error} Invalid options
@@ -506,6 +508,12 @@ function webp (options) {
throw is.invalidParameterError('effort', 'integer between 0 and 6', effort);
}
}
if (is.defined(options.minSize)) {
this._setBooleanOption('webpMinSize', options.minSize);
}
if (is.defined(options.mixed)) {
this._setBooleanOption('webpMixed', options.mixed);
}
}
trySetAnimationOptions(options, this.options);
return this._updateFormatOut('webp', options);