PHPackages                             bensquire/php-image-optim - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. bensquire/php-image-optim

AbandonedArchivedLibrary[Image &amp; Media](/categories/media)

bensquire/php-image-optim
=========================

A library to aid in image optimisation

2.2.0(4y ago)8642.8k19[5 issues](https://github.com/bensquire/php-image-optim/issues)[1 PRs](https://github.com/bensquire/php-image-optim/pulls)1MITPHPPHP &gt;=7.3.0

Since Jun 3Pushed 4y ago7 watchersCompare

[ Source](https://github.com/bensquire/php-image-optim)[ Packagist](https://packagist.org/packages/bensquire/php-image-optim)[ Docs](https://github.com/bensquire/php-image-optim)[ RSS](/packages/bensquire-php-image-optim/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (3)Versions (13)Used By (1)

php-image-optim
===============

[](#php-image-optim)

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

Installation:
-------------

[](#installation)

### Library

[](#library)

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

```
composer require bensquire/php-image-optim

```

into your composer.json, then run 'composer install' or 'composer update' as required.

### Binaries

[](#binaries)

#### MacOS

[](#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:

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

Example
-------

[](#example)

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

```
