2017 © Pedro Peláez
 

library php-image-optim

A library to aid in image optimisation

image

bensquire/php-image-optim

A library to aid in image optimisation

  • Saturday, July 21, 2018
  • by bensquire
  • Repository
  • 11 Watchers
  • 66 Stars
  • 15,284 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 22 Forks
  • 1 Open issues
  • 10 Versions
  • 6 % Grown

The README.md

php-image-optim

The purpose of this library is to help automate the optimisation of images via the command line in PHP,, (*1)

Installation:

Library

The library is PSR-4 compliant and the simplest way to install it is via composer, simply add:, (*2)

composer require bensquire/php-image-optim

into your composer.json, then run 'composer install' or 'composer update' as required., (*3)

Binaries

MacOS

brew install Advancecomp # AdvPNG
brew install gifsicle
brew install guetzli
brew install jonof/kenutils/pngout
brew install jpeg # JPEGTran
brew install jpegoptim
brew install mozjpeg
brew install optipng
brew install pngcrush
brew install pngquant
brew install zopfli # Future
brew install svgo # Future

It's worth noting that mozJpeg is a fork of libjpeg-turbo and as such isn't a binary with it's own name, for example to use it in this library:, (*4)

$tool = new \PHPImageOptim\Tools\Jpeg\MozJpeg();
$tool->setBinaryPath('/usr/local/opt/mozjpeg/bin/jpegtran');

Example

This example demonstrates the optimisation of a PNG file, by chaining several commands together., (*5)

<?php
    include('./vendor/autoload.php');

    use PHPImageOptim\Tools\Png\AdvPng;
    use PHPImageOptim\Tools\Png\OptiPng;
    use PHPImageOptim\Tools\Png\PngCrush;
    use PHPImageOptim\Tools\Png\PngOut;
    use PHPImageOptim\Tools\Png\PngQuant;

    $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('./tests/image/lenna.png');
    $optim->chainCommand($pngQuant)
        ->chainCommand($advPng)
        ->chainCommand($optiPng)
        ->chainCommand($pngCrush)
        ->chainCommand($pngOut);
    $optim->optimise();

Tooling

Fix common coding inconsistencies

    composer php-cs-fixer

Find coding issues

    composer php-stan

Run unit tests

    composer tests

TODO:

Add zopfli support?, (*6)

Add svgo support?, (*7)

The Versions

21/07 2018

dev-master

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

A library to aid in image optimisation

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

php gif image jpg png optimisation

20/06 2018

2.0.1

2.0.1.0 https://github.com/bensquire/php-image-optim

A library to aid in image optimisation

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

php gif image jpg png optimisation

02/04 2018

2.0.0

2.0.0.0 https://github.com/bensquire/php-image-optim

A library to aid in image optimisation

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

php gif image jpg png optimisation

02/04 2018

dev-PHP7

dev-PHP7 https://github.com/bensquire/php-image-optim

A library to aid in image optimisation

  Sources   Download

MIT

The Requires

  • php >=7.0.0

 

The Development Requires

php gif image jpg png optimisation

02/04 2018

1.2.2

1.2.2.0 https://github.com/bensquire/php-image-optim

A library to aid in image optimisation

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

php gif image jpg png optimisation

18/04 2017

1.2.1

1.2.1.0 https://github.com/bensquire/php-image-optim

A library to aid in image optimisation

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

php gif image jpg png optimisation

17/04 2017

1.2.0

1.2.0.0 https://github.com/bensquire/php-image-optim

A library to aid in image optimisation

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

php gif image jpg png optimisation

07/03 2016

1.1.0

1.1.0.0 https://github.com/bensquire/php-image-optim

A library to aid in image optimisation

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

php gif image jpg png optimisation

05/03 2016

1.0.0

1.0.0.0 https://github.com/bensquire/php-image-optim

A library to aid in image optimisation

  Sources   Download

MIT

The Requires

  • php >=5.6.0
  • ext-hash *

 

The Development Requires

php gif image jpg png optimisation

03/06 2014

0.9.0

0.9.0.0 https://github.com/bensquire/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