dev-master
9999999-dev https://github.com/elfeffe/php-image-optimA library to aid in image optimisation
MIT
The Requires
- php >=5.3.0
- ext-hash *
The Development Requires
by Ben Squire
php gif image jpg png optimisation
Wallogit.com
2017 © Pedro Peláez
A library to aid in image optimisation
This is a fork of bensquire library, where I plan to add some other tools., (*1)
The purpose of this library is to help automate the optimisation of images via the command line in PHP,, (*2)
The library is PSR-0 compliant and the simplest way to install it is via composer, simply add:, (*3)
{
"require": {
"elfeffe/php-image-optim": "dev-master"
}
}
into your composer.json, then run 'composer install' or 'composer update' as required., (*4)
This example demonstrates the optimisation of a PNG file, by chaining several commands together., (*5)
<?php
use PHPImageOptim\PHPImageOptim,
PHPImageOptim\Tools\Png\OptiPng,
PHPImageOptim\Tools\Png\PngCrush,
PHPImageOptim\Tools\Png\PngQuant;
include('../../vendor/autoload.php');
$advPng = new AdvPng();
$advPng->setBinaryPath('/usr/local/bin/advpng');
$optiPng = new OptiPng();
$optiPng->setBinaryPath('/usr/local/bin/optipng');
$pngOut = new PngOut();
$pngOut->setBinaryPath('/usr/bin/pngout');
$pngCrush = new PngCrush();
$pngCrush->setBinaryPath('/usr/local/bin/pngcrush');
$pngQuant = new PngQuant();
$pngQuant->setBinaryPath('/usr/local/bin/pngquant');
$optim = new PHPImageOptim();
$optim->setImage('/tmp/lenna.png');
$optim ->chainCommand($pngQuant)
->chainCommand($advPng)
->chainCommand($optiPng)
->chainCommand($pngCrush)
->chainCommand($pngOut);
$optim->optimise();
A library to aid in image optimisation
MIT
php gif image jpg png optimisation