PHP code example of rosell-dk / webp-convert-and-serve
1. Go to this page and download the library: Download rosell-dk/webp-convert-and-serve library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rosell-dk / webp-convert-and-serve example snippets
use WebPConvertAndServe\WebPConvertAndServe;
$source = __DIR__ . '/logo.jpg';
$destination = $source . '.webp';
$options = [
'fail' => 'original',
'critical-fail' => '404',
// You can specify any WebPConvert option here - such as defining a converters array, which
// is needed, if you need to use a cloud converter
'converters' => [
[
'converter' => 'ewww',
'options' => [
'key' => 'blah',
],
],
'cwebp',
'gd'
];
$status = WebPConvertAndServe::convertAndServe($source, $destination, $options);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.