PHP code example of gtuk / image-optimizer
1. Go to this page and download the library: Download gtuk/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/ */
gtuk / image-optimizer example snippets
$optimizer = new Optimizer(
array(
Optimizer::PNGQUANT_PATH => '/usr/local/bin/pngquant',
Optimizer::MOZJPEG_PATH => '/usr/local/bin/cjpeg',
Optimizer::GIFSICLE_PATH => '/usr/local/bin/gifsicle'
)
);
$optimizer->optimize('example.jpg', 'example-optimized.jpg'));