PHP Function ImageWebp
The php function imagewebp converts a web-ready PNG image into a webp file that can be served as an image. This can help reduce the size of images and lower bandwidth usage. This is especially useful if you have many images in your site.
To use the php function imagewebp, you'll need a web host that supports the WebP format. You can check if your host supports WebP by calling the phpinfo() function or the php -i CLI command. If your host doesn't support WebP, you can still enable it by installing the libavif package and compiling PHP with AVIF support.
This function requires a GdImage object as the first parameter. It also accepts a path or an open stream resource to save the WebP image to. The final argument is a quality value that can range from 0 (worst quality, smaller file) to 100 (best quality, largest file). The function returns a GdImage instance on success or a False for failure.
If you're running a ProcessWire website on an environment that supports WebP, it makes sense to use the imagewebp function in your code to generate WebP files of your images. You can then include these WebP files in your HTML pages using the
Using the WebP image format reduces file sizes by a significant amount. This can help your web pages load faster and reduce bandwidth usage for your visitors.