PHP code example of buglinjo / laravel-webp

1. Go to this page and download the library: Download buglinjo/laravel-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/ */

    

buglinjo / laravel-webp example snippets


Buglinjo\LaravelWebp\WebpServiceProvider::class,

'Webp' => Buglinjo\LaravelWebp\Facades\Webp::class,

return [
    /*
    |--------------------------------------------------------------------------
    | Default Quality
    |--------------------------------------------------------------------------
    |
    | This is a default quality unless you provide while generation of the WebP
    |
    */
    'default_quality' => 70,

    /*
    |--------------------------------------------------------------------------
    | Default Driver
    |--------------------------------------------------------------------------
    |
    | This is a default image processing driver. Available: ['cwebp', 'php-gd']
    |
    */
    'default_driver' => 'php-gd',

    /*
    |--------------------------------------------------------------------------
    | Drivers
    |--------------------------------------------------------------------------
    |
    | Available drivers which can be selected
    |
    */
    'drivers' => [

        /*
        |--------------------------------------------------------------------------
        | Cwebp Driver
        |--------------------------------------------------------------------------
        |
        | If you choose cwebp driver it is 

Webp::make(<UploadedFile image>)->save(<output path>, <quality :optional>);

    $webp = Webp::make($request->file('image'));

    if ($webp->save(public_path('output.webp'))) {
        // File is saved successfully
    }

php artisan vendor:publish --provider="Buglinjo\LaravelWebp\WebpServiceProvider" --tag=config