PHP code example of luova / imageoptimizer

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

    

luova / imageoptimizer example snippets


Luova\ImageOptimizer\ImageOptimizerServiceProvider::class,


    use Luova\ImageOptimizer\Optimizer;

    $optimizer = new Optimizer();
    // first parameter for image file path, second parameter for where you want save optimize image and third parameter for image qualify

    // the image will be replaced with an optimized version which should be smaller
    $info = $optimizer->optimize($file);
    // if you use a second parameter the package will not modify the original
    $info = $optimizer->optimize($file, $optimize_path);
     // if you use a third parameter for image qualify
    $info = $optimizer->optimize($file, $optimize_path,80);