Image Quality & Options
Image quality is set per-format, using
format_quality: (format): 0 <= integer <= 100 (...)
format_quality: jpg: 75 png: 65 webp: 55
- webp - 50
- avif - 30
- jp2 - 30
- all others - 75
format_quality: (format): (image width): (quality setting) (image width): (quality setting)
format_quality: jpg: 1000: 65 300: 100
Set a variable image quality, based on image width. Provide exactly 2 image widths and associated quality settings. Quality will be calculated as follows:
- For images smaller than the lowest image width, the setting for the lowest width is used.
- For images larger than the highest image width, the setting for the highest width is used.
- For images in between the 2, the quality setting will be linearly interpolated to some value in between.
Using this setting, you can get away with more compression on high pixel density screens without sacrificing image quality for low-density screens. Taking the example settings above:
- A 1500px image will use a quality of 65.
- A 200px image will use a quality of 100.
- A 500px image will use a quality of 90.
Remove EXIF data, which can save a few tens of kilobytes per image. This is set for all formats.
Image Format Options
image_options: format: setting1: value setting2: value (...) (...)
image_options: webp: lossless: true
image_options: avif: compression: av1 speed: 8
Control the write options passed to libvips for each image output format. To see a list of options available for a given image format, search for the method
vips_(format)save in this API documentation. For example, png options can be found by searching for
vips_pngsave(), leading here. See the optional arguments.
avif's options are under
For all formats, note that
Q:(quality) is handled by the settings above.
stripis handled by the
strip_metadatasetting documented above.