lciolecki / php-image-optimizer
PHP image file optimizer (uses https://github.com/bensquire/php-image-optim)
Installs: 7 083
Dependents: 0
Suggesters: 0
Security: 0
Stars: 33
Watchers: 5
Forks: 10
Open Issues: 1
Requires
- php: >=5.4
- bensquire/php-image-optim: dev-master
Requires (Dev)
- phpunit/phpunit: 3.7.*
This package is not auto-updated.
Last update: 2024-11-20 14:02:47 UTC
README
This is a simple PHP class for optimize image file uses https://github.com/bensquire/php-image-optim (png, jpeg, gif). Requires: optipng, jpegoptim, gifsicle
##Installation using Composer
{
"minimum-stability": "dev",
"require": {
"lciolecki/php-image-optimizer": "dev-master"
}
}
Sample use
$optimizer = new \Extlib\ImageOptimizer(array(
\Extlib\ImageOptimizer::OPTIMIZER_OPTIPNG => '/usr/bin/optipng', //your_path
\Extlib\ImageOptimizer::OPTIMIZER_JPEGOPTIM => '/usr/bin/jpegoptim', //your_path
\Extlib\ImageOptimizer::OPTIMIZER_GIFSICLE => '/usr/bin/gifsicle' //your_path
));
$optimizer->optimize("image.png"); //return true
$optimizer->optimize("image.jpg"); //return true
$optimizer->optimize("image.gif"); //return true
$optimizer->optimize("file.txt"); //return false
If you don't have some one of packages: optipng, jpegoptim, gifsicle optimizer throws Exception. For save uses take all code in try/catch block.