gtuk / image-optimizer
PHP image optimizer for png, jpeg and gif files. It uses mozjpeg, pngquant and gifsicle for the optimization process
Installs: 1 425
Dependents: 0
Suggesters: 0
Security: 0
Stars: 16
Watchers: 4
Forks: 1
Open Issues: 1
Requires
- php: >=5.4
Requires (Dev)
- phpunit/phpunit: ~4.8
This package is not auto-updated.
Last update: 2025-01-04 21:52:34 UTC
README
PHP image optimizer for png, jpeg and gif files. It uses mozjpeg, pngquant and gifsicle for the optimization process.
This guide assumes you have mozjpeg, pngquant and gifsicle installed.
Installation
You can install this library with composer or include it manually in your project.
Quick start
$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' ) );
After this you can run the optimization process. If the optimization failed the method will throw an Exception, otherwise it returns TRUE.
$optimizer->optimize('example.jpg', 'example-optimized.jpg'));