PHPackages                             slicklabs/image - 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. slicklabs/image

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

slicklabs/image
===============

All Slick image related functionality

00PHP

Since Feb 21Pushed 7y ago2 watchersCompare

[ Source](https://github.com/wefabric/image)[ Packagist](https://packagist.org/packages/slicklabs/image)[ RSS](/packages/slicklabs-image/feed)WikiDiscussions master Synced 4d ago

READMEChangelogDependenciesVersions (1)Used By (0)

Easily manipulate images using PHP
==================================

[](#easily-manipulate-images-using-php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/b96b790f88f0d735eb200c345251350e70620ff7945759e60094fa047d3e6dc3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5061636b61676973742d312e302e302d627269676874677265656e2e737667)](https://packagist.org/packages/slicklabs/image)[![Quality Score](https://camo.githubusercontent.com/447c28cac6ee486628ca8c8b106632be7f8b8f71ee1bdb610a74783f920c1521/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7370617469652f696d6167652d6f7074696d697a65722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/spatie/image-optimizer)

This package is heavily inspired by Image Optimizer from Spatie, but is a more common approach on image optimization.

This package can optimize and resize PNGs, JPGs, SVGs and GIFs by running them through a chain of various tools. Here's how you can use it:

```
use Slick\Image\Optimizer;

$slickImageOptimizer = new Optimizer();

$slickImageOptimizer->optimize($pathToImage);
```

The image at `$pathToImage` will be overwritten by an optimized and resized version which should be smaller. The package will automatically detect which optimization binaries are installed on your system and use them.

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require slicklabs/image
```

### Optimization tools

[](#optimization-tools)

The package will use these optimizers if they are present on your system:

- [Intervention Image](https://github.com/intervention/image/)
- [Spatie Image Optimizer](https://github.com/spatie/image-optimizer)

Here's how to install all the optimizers on Ubuntu:

```
sudo apt-get install jpegoptim
sudo apt-get install optipng
sudo apt-get install pngquant
sudo npm install -g svgo
sudo apt-get install gifsicle
```

And here's how to install the binaries on MacOS (using [Homebrew](https://brew.sh/)):

```
brew install jpegoptim
brew install optipng
brew install pngquant
brew install svgo
brew install gifsicle
```

Which tools will do what?
-------------------------

[](#which-tools-will-do-what)

The package will automatically decide which tools to use on a particular image.

### JPGs

[](#jpgs)

JPGs will be made smaller by running them through [JpegOptim](http://freecode.com/projects/jpegoptim). These options are used:

- `-m85`: this will store the image with 85% quality. This setting [seems to satisfy Google's Pagespeed compression rules](https://webmasters.stackexchange.com/questions/102094/google-pagespeed-how-to-satisfy-the-new-image-compression-rules)
- `--strip-all`: this strips out all text information such as comments and EXIF data
- `--all-progressive`: this will make sure the resulting image is a progressive one, meaning it can be downloaded using multiple passes of progressively higher details.

### PNGs

[](#pngs)

PNGs will be made smaller by running them through two tools. The first one is [Pngquant 2](https://pngquant.org/), a lossy PNG compressor. We set no extra options, their defaults are used. After that we run the image through a second one: [Optipng](http://optipng.sourceforge.net/). These options are used:

- `-i0`: this will result in a non-interlaced, progressive scanned image
- `-o2`: this set the optimization level to two (multiple IDAT compression trials)

### SVGs

[](#svgs)

SVGs will be minified by [SVGO](https://github.com/svg/svgo). SVGO's default configuration will be used, with the omission of the `cleanupIDs` plugin because that one is known to cause troubles when displaying multiple optimized SVGs on one page.

Please be aware that SVGO can break your svg. You'll find more info on that in this [excellent blogpost](https://www.sarasoueidan.com/blog/svgo-tools/) by [Sara Soueidan](https://twitter.com/SaraSoueidan).

### GIFs

[](#gifs)

GIFs will be optimized by [Gifsicle](http://www.lcdf.org/gifsicle/). These options will be used:

- `-O3`: this sets the optimization level to Gifsicle's maximum, which produces the slowest but best results

Usage
-----

[](#usage)

This is the default way to use the package:

```
use Slick\Image\Optimizer;

$slickImageOptimizer = new Optimizer();

$slickImageOptimizer->optimize($pathToImage);
```

The image at `$pathToImage` will be overwritten by an optimized version which should be smaller.

The package will automatically detect which optimization binaries are installed on your system and use them.

### Bulk usage

[](#bulk-usage)

You might opt for the bulk implementation which accepts a source and destination folder and will create a new folder with optimized images.

```
use Slick\Image\BulkOptimizer;

$slickBulkImageOptimizer = new BulkOptimizer([
    'width' => 1600,
    'height' => 1600,
    'source' => $pathToSourceFolder
    'dest' => $pathToDestionationFolder
]);

$slickBulkImageOptimizer->optimize();
```

If the destination folder does not exist. It will automatically create one.

### Command line usage

[](#command-line-usage)

This package also provides a command line approach. If you would like to use this functionality you will have to install it as a separate package. After that the basic usage is:

```
php bin/console slick-image:optimize-image --source='/Users/USER/source' --dest='/Users/USER/dest'
```

This will use the BulkOptimizer. It will also output the progress of the optimizations.

Logging the optimization process
--------------------------------

[](#logging-the-optimization-process)

By default the package will not throw any errors and just operate silently. To verify what the package is doing you can set a logger:

```
use Slick\Image\BulkOptimizer;

$slickBulkImageOptimizer = new BulkOptimizer([
    'source' => $pathToSourceFolder
    'dest' => $pathToDestionationFolder
]);

$slickBulkImageOptimizer->setLogger(new MyLogger());

$slickBulkImageOptimizer->optimize();
```

A logger is a class that implements `Psr\Log\LoggerInterface`. A good logging library that's fully compliant is [Monolog](https://github.com/Seldaek/monolog). The package will write to log which `Optimizers` are used, which commands are executed and their output.

Changelog
---------

[](#changelog)

No changelog to display yet

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Nathan Jansen](https://wefabric.nl)
- [Freek Van der Herten](https://github.com/freekmurze)
- [All Contributors](../../contributors)

This package has been inspired by [Intervention Image](https://github.com/intervention/image/)

License
-------

[](#license)

The MIT License (MIT).

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/8834dc84f62a7c139ded639124a4f9a3bfd03e8ccac75db9f83107ed38ebca39?d=identicon)[slicklabs](/maintainers/slicklabs)

### Embed Badge

![Health badge](/badges/slicklabs-image/health.svg)

```
[![Health](https://phpackages.com/badges/slicklabs-image/health.svg)](https://phpackages.com/packages/slicklabs-image)
```

###  Alternatives

[milon/barcode

Barcode generator like Qr Code, PDF417, C39, C39+, C39E, C39E+, C93, S25, S25+, I25, I25+, C128, C128A, C128B, C128C, 2-Digits UPC-Based Extention, 5-Digits UPC-Based Extention, EAN 8, EAN 13, UPC-A, UPC-E, MSI (Variation of Plessey code)

1.5k13.3M39](/packages/milon-barcode)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[goat1000/svggraph

Generates SVG graphs

132849.6k3](/packages/goat1000-svggraph)[cohensive/embed

Media Embed (for Laravel or as a standalone).

120370.4k](/packages/cohensive-embed)[netresearch/rte-ckeditor-image

Image support in CKEditor for the TYPO3 ecosystem - by Netresearch

63991.3k4](/packages/netresearch-rte-ckeditor-image)[humanmade/tachyon-plugin

Rewrites WordPress image URLs to use Tachyon

87338.5k2](/packages/humanmade-tachyon-plugin)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
