WebP Conversion
How Does It Work?
Automatically converts jpeg/pngs to WebP if WebP is not available. Automatically serve WebP images (if the webp is smaller than the original) instead of jpeg/pngs for browsers that supports WebP.
Conversion Methods
List of library that is able to convert images to webp using variety of methods, the list are listed from greatest to least.
- cwebp (executing cwebp binary using an exec call)
- imagick (using Imagick PHP extension)
- gmagick (using Gmagick PHP extension)
- gd (using the Gd PHP extension)
In addition to converting, the library also has a method for serving converted images.
Options
You can set the quality, metadata by modifying the following options.
JPG/PNG Options
- Metadata - Only cwebp supports all values. gd will always remove all metadata. The rest can either strip all or keep all (they will keep all, unless the option is set to none).
- Encoding - Encoded media files are typically similar in quality to their original uncompressed counterparts, but have much smaller file sizes
- Quality - Specify the level of image quality
- Lossless/Fallback Quality - Specify the level of near-lossless/lossy image preprocessing. This option adjusts pixel values to help compressibility, but has minimal impact on the visual quality. It triggers lossless/lossy compression mode automatically. The range is 0 (maximum preprocessing) to 100 (no preprocessing). The typical value is around 60.
Last updated on