PHP code example of guizoxxv / laravel-multi-size-image

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

    

guizoxxv / laravel-multi-size-image example snippets


use Guizoxxv\LaravelMultiSizeImage\MultiSizeImage;

...

$multiSizeImage = new MultiSizeImage();

$filePath = Storage::path('folder/file.png');

$multiSizeImage->processImage($filePath);

$multiSizeImage->processImage($filePath, $outputPath, $basePath);

'sizes' => [
    'tb' => 150,
    'sm' => 300,
    'lg' => 1024,
]

$multiSizeImage->processImage($filePath, $outputPath, $basePath, $fileName);

$optimizerChain = (new OptimizerChain)
    ->addOptimizer(new Jpegoptim([
        '-m85',
        '--strip-all',
        '--all-progressive',
    ]))
    ->addOptimizer(new Pngquant([
        '--force',
    ]))
    ->addOptimizer(new Optipng([
        '-i0',
        '-o2',
        '-quiet',
    ]));

use Guizoxxv\LaravelMultiSizeImage\MultiSizeImage;
use Spatie\ImageOptimizer\Optimizers\Svgo;
use Spatie\ImageOptimizer\Optimizers\Optipng;
use Spatie\ImageOptimizer\Optimizers\Gifsicle;
use Spatie\ImageOptimizer\Optimizers\Pngquant;
use Spatie\ImageOptimizer\Optimizers\Jpegoptim;
use Spatie\ImageOptimizer\Optimizers\Cwebp;

...

$optimizerChain = (new OptimizerChain)
    ->addOptimizer(new Jpegoptim([
        '-m85',
        '--strip-all',
        '--all-progressive',
    ]))
    ->addOptimizer(new Pngquant([
        '--force',
    ]))
    ->addOptimizer(new Optipng([
        '-i0',
        '-o2',
        '-quiet',
    ]))
    ->addOptimizer(new Svgo([
        '--disable=cleanupIDs',
    ]))
    ->addOptimizer(new Gifsicle([
        '-b',
        '-O3'
    ]))
    ->addOptimizer(new Cwebp([
        '-m 6',
        '-pass 10',
        '-mt',
        '-q 90',
    ]));

$multiSizeImage = new MultiSizeImage($optimizerChain);

$ php artisan vendor:publish --provider="Guizoxxv\LaravelMultiSizeImage\MultiSizeImageServiceProvider"