In case you don't know if your webserver is already configured well and can use WebP, please follow these steps to check:

1. Create a new testwebp.php  file in your Magento 2 root directory.

2. Add this code to it:


$errorSufix = '<br/>Please enable it in your hosting configuration or ask the server administrator to help you with this.</strong>';

if (!function_exists('gd_info')) {
   echo ('<strong style="color:red">Error: GD is not enabled in PHP settings.' . $errorSufix);
exit(); } $hasWebP = false; foreach (gd_info() as $key => $value) { if (stristr($key, 'webp')) { $hasWebP = true; break; } } if (!$hasWebP) { echo ('<strong style="color:red">Error: WebP option is not enabled in PHP GD.' . $errorSufix);
exit(); } if (!function_exists('imagecreatefromwebp')) { echo ('<strong style="color:red">Error: imagecreatefromwebp function does not exist.' . $errorSufix);
exit(); } echo ('<strong style="color:green">Success.<br/>Your PHP settings are ready for WEBP.</strong>');

3. Save the file.

4. Open this URL in your browser

If you cannot access testwebp.php in your browser, then try to run CLI command inside Magento 2 folder:

php testwebp.php

If you see the success message, then your server is ready for WebP and you can start configuring Magento 2 WebP images.

If not, you will need to change the PHP settings in the hosting panel or ask the server administrator to set configurations.