PHP code example of uxcode-fr / image-optimizer

1. Go to this page and download the library: Download uxcode-fr/image-optimizer 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/ */

    

uxcode-fr / image-optimizer example snippets


return [
    'source'      => 'resources/images',
    'destination' => 'public/img',

    'quality' => [
        'avif' => 60,
        'webp' => 82,
        'jpg'  => 85,
    ],

    'formats'   => ['avif', 'webp', 'jpg'],
    'densities' => [1, 2],

    'folders' => [
        'product' => [200, 280],   // generates -200, -200@2x, -280, -280@2x variants
        'author'  => [48, 128],
        'article' => null,         // convert only, no resize
    ],
];
bash
php artisan vendor:publish --tag=image-optimizer-config
bash
cp vendor/uxcode-fr/image-optimizer/config/image-optimizer.php config/image-optimizer.php