Make WebP or AVIF copies of a site's images
convert_imagesMake WebP (or AVIF) copies of the JPEG and PNG images in a site's upload folders, next to each original as .webp, with the encoder the server has (cwebp, avifenc, ImageMagick or vips; the answer names it, or says what to install). Runs as the site's owner in the background: follow with job_output, the last line is the summary (converted, already had a copy, no gain, MB before and after). Originals are never changed, and a copy that is not smaller is removed. dry_run true only counts. Serving the copies is separate: nginx needs a map on the Accept header and try_files $uri$webp_suffix (add_header Vary Accept); Apache a RewriteCond on HTTP_ACCEPT; WordPress and Magento can also serve them through their own image settings. Tell the user that before converting, and run it again later for new uploads (existing copies are skipped).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| site | No | Site root folder, like /var/www/shop, or one of the site's domains. Optional when the server has one site (see list_sites). | |
| format | No | Default webp (every browser; AVIF is smaller but slower to make). | |
| server | No | Server name or id. Optional when the account has one server. | |
| dry_run | No | ||
| folders | No | Folders relative to the site root; default: the site's upload folders (wp-content/uploads, pub/media, ...). | |
| quality | No | 1 to 100; default 82 for WebP, 55 for AVIF. | |
| max_files | No | Stop after this many conversions (default and most 20000). |