2017 © Pedro Peláez
 

library php-image-optim

A library to aid in image optimisation

image

elfeffe/php-image-optim

A library to aid in image optimisation

  • Thursday, September 3, 2015
  • by elfeffe
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 21 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

php-image-optim

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)

Installation:

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)

Example:

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();

The Versions

03/09 2015

dev-master

9999999-dev https://github.com/elfeffe/php-image-optim

A library to aid in image optimisation

  Sources   Download

MIT

The Requires

  • php >=5.3.0
  • ext-hash *

 

The Development Requires

php gif image jpg png optimisation