lib/output.js
function webp (options) {
  if (is.object(options) && is.defined(options.quality)) {
    if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {
      this.options.webpQuality = options.quality;
    } else {
      throw new Error('Invalid quality (integer, 1-100) ' + options.quality);
    }
  }
  if (is.object(options) && is.defined(options.alphaQuality)) {
    if (is.integer(options.alphaQuality) && is.inRange(options.alphaQuality, 0, 100)) {
      this.options.webpAlphaQuality = options.alphaQuality;
    } else {
      throw new Error('Invalid webp alpha quality (integer, 0-100) ' + options.alphaQuality);
    }
  }
  if (is.object(options) && is.defined(options.lossless)) {
    this._setBooleanOption('webpLossless', options.lossless);
  }
  if (is.object(options) && is.defined(options.nearLossless)) {
    this._setBooleanOption('webpNearLossless', options.nearLossless);
  }
  return this._updateFormatOut('webp', options);
}
function webp (options) {
  if (is.object(options) && is.defined(options.quality)) {
    if (is.integer(options.quality) && is.inRange(options.quality, 1, 100)) {
      this.options.webpQuality = options.quality;
    } else {
      throw new Error('Invalid quality (integer, 1-100) ' + options.quality);
    }
  }
  if (is.object(options) && is.defined(options.alphaQuality)) {
    if (is.integer(options.alphaQuality) && is.inRange(options.alphaQuality, 0, 100)) {
      this.options.webpAlphaQuality = options.alphaQuality;
    } else {
      throw new Error('Invalid webp alpha quality (integer, 0-100) ' + options.alphaQuality);
    }
  }
  if (is.object(options) && is.defined(options.lossless)) {
    this._setBooleanOption('webpLossless', options.lossless);
  }
  if (is.object(options) && is.defined(options.nearLossless)) {
    this._setBooleanOption('webpNearLossless', options.nearLossless);
  }
  return this._updateFormatOut('webp', options);
}
function webp ( options ) { if ( is . object ( options ) && is . defined ( options . quality ) ) { if ( is . integer ( options . quality ) && is . inRange ( options . quality , 1 , 100 ) ) { this . options . webpQuality = options . quality ; } else { throw new Error ( 'Invalid quality (integer, 1-100) ' + options . quality ) ; } } if ( is . object ( options ) && is . defined ( options . alphaQuality ) ) { if ( is . integer ( options . alphaQuality ) && is . inRange ( options . alphaQuality , 0 , 100 ) ) { this . options . webpAlphaQuality = options . alphaQuality ; } else { throw new Error ( 'Invalid webp alpha quality (integer, 0-100) ' + options . alphaQuality ) ; } } if ( is . object ( options ) && is . defined ( options . lossless ) ) { this . _setBooleanOption ( 'webpLossless' , options . lossless ) ; } if ( is . object ( options ) && is . defined ( options . nearLossless ) ) { this . _setBooleanOption ( 'webpNearLossless' , options . nearLossless ) ; } return this . _updateFormatOut ( 'webp' , options ) ; }
Use these WebP options for output image.

@example
// Convert any input to lossless WebP output
const data = await sharp(input)
.webp({ lossless: true })
.toBuffer();

@param {Object} [options] - output options
@param {Number} [options.quality=80] - quality, integer 1-100
@param {Number} [options.alphaQuality=100] - quality of alpha layer, integer 0-100
@param {Boolean} [options.lossless=false] - use lossless compression mode
@param {Boolean} [options.nearLossless=false] - use near_lossless compression mode
@param {Boolean} [options.force=true] - force WebP output, otherwise attempt to use input format
@returns {Sharp}
@throws {Error} Invalid options
Use these WebP options for output image .