PHP code example of codeblog / conveter-php-webp

1. Go to this page and download the library: Download codeblog/conveter-php-webp 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/ */

    

codeblog / conveter-php-webp example snippets




// Initialise your autoloader (this example is using Composer)
 'image-new.webp';

$wp = new ToWebP('uploads', "images");
$wp->convert($source, $destination);

echo $wp->image_webp;



// Initialise your autoloader (this example is using Composer)
 'image-new.webp';
$quality = 90;

$wp = new ToWebP('uploads', "images");
$wp->convert($source, $destination, $quality);

$arr =[
    'picture' => [
        'class' => 'responsive'
    ],
    'img' => [
        'alt' => 'Image converted with the ToWebP library',
        'style'=>'width: 400px;'
    ]
];

echo $wp->picture($arr);
bash
"codeblog/conveter-php-webp": "^1.0"
bash
composer