function toFormat (format, options) {
  const actualFormat = formats.get((is.object(format) && is.string(format.id) ? format.id : format).toLowerCase());
  if (!actualFormat) {
    throw is.invalidParameterError('format', `one of: ${[...formats.keys()].join(', ')}`, format);
  }
  return this[actualFormat](options);
}
Force output to a given format.

@example
// Convert any input to PNG output
const data = await sharp(input)
  .toFormat('png')
  .toBuffer();

@param {(string|Object)} format - as a string or an Object with an 'id' attribute
@param {Object} options - output options
@returns {Sharp}
@throws {Error} unsupported format or options