Add WebP 'exact' option for control over transparent pixels

This commit is contained in:
Lovell Fuller
2026-01-01 19:19:20 +00:00
parent 1cf4b7f04d
commit 0d872bd13a
9 changed files with 47 additions and 4 deletions

View File

@@ -749,6 +749,7 @@ function png (options) {
* @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.exact=false] - preserve the colour data in transparent pixels
* @param {boolean} [options.force=true] - force WebP output, otherwise attempt to use input format
* @returns {Sharp}
* @throws {Error} Invalid options
@@ -801,6 +802,9 @@ function webp (options) {
if (is.defined(options.mixed)) {
this._setBooleanOption('webpMixed', options.mixed);
}
if (is.defined(options.exact)) {
this._setBooleanOption('webpExact', options.exact);
}
}
trySetAnimationOptions(options, this.options);
return this._updateFormatOut('webp', options);