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

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

kirapwn/image-optimizer
=======================

Image optimization / compression library. This library is able to optimize png, jpg and gif files in very easy and handy way. It uses optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim and jpegtran tools.

1.0.9(9y ago)029MITPHP

Since Aug 3Pushed 9y ago1 watchersCompare

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

READMEChangelog (3)Dependencies (3)Versions (11)Used By (0)

Image Optimizer
===============

[](#image-optimizer)

This library is handy and very easy to use optimizer for image files. It uses [optipng](http://optipng.sourceforge.net/), [pngquant](http://pngquant.org/), [jpegoptim](http://freecode.com/projects/jpegoptim) and few more libraries, so before use it you should install proper libraries on your server. Project contains Vagrantfile that defines testing virtual machine with all libraries installed, so you can check Vagrantfile how to install all those stuff.

Thanks to ImageOptimizer and librares that it uses, your image files can be **10%-70% smaller**.

Basic usage
===========

[](#basic-usage)

```
    $factory = new \ImageOptimizer\OptimizerFactory();
    $optimizer = $factory->get();

    $filepath = /* path to image */;

    $optimizer->optimize($filepath);
    //optimized file overwrites original one
```

Configuration
=============

[](#configuration)

By default optimizer does not throw any exception, if file can not be optimized or optimizing library for given file is not installed, optimizer will not touch original file. This behaviour is ok when you want to eventually optimize files uploaded by user. When in your use case optimization fault should cause exception, `ignore_errors` option was created especially for you.

This library is very smart, you do not have to configure paths to all binaries of libraries that are used by ImageOptimizer, library will be looking for those binaries in few places, so if binaries are placed in standard places, it will be found automatically.

Supported options:

- `ignore_errors` (default: true)
- `optipng_options` (default: `array('-i0', '-o2', '-quiet')`) - an array of arguments to pass to the library
- `pngquant_options` (default: `array('--force')`)
- `pngcrush_options` (default: `array('-reduce', '-q', '-ow')`)
- `pngout_options` (default: `array('-s3', '-q', '-y')`)
- `gifsicle_options` (default: `array('-b', '-O5')`)
- `jpegoptim_options` (default: `array('--strip-all', '--all-progressive', '--max=90')`)
- `jpegtran_options` (default: `array('-optimize', '-progressive')`)
- `optipng_bin` (default: will be guessed) - you can enforce paths to binaries, but by default it will be guessed
- `pngquant_bin`
- `pngcrush_bin`
- `pngout_bin`
- `gifsicle_bin`
- `jpegoptim_bin`
- `jpegtran_bin`

You can pass array of options as first argument of `ImageOptimizer\OptimizerFactory` constructor. Second argument is optionally `Psr\LoggerInterface`.

```
    $factory = new \ImageOptimizer\OptimizerFactory(array('ignore_errors' => false), $logger);
```

Supported optimizers
====================

[](#supported-optimizers)

- default (`smart`) - it guess file type and choose optimizer for this file type
- `png` - chain of optimizers for png files, by default it uses `pngquant` and `optipng`. `pngquant` is lossy optimization
- `jpg` - first of two optimizations will be executed: `jpegtran` or `jpegoptim`
- `gif` - alias to `gifsicle`
- `pngquant` - [homepage](http://pngquant.org/)
- `optipng` - [homepage](http://optipng.sourceforge.net/)
- `pngcrush` - [homepage](http://pmt.sourceforge.net/pngcrush/)
- `pngout` - [homepage](http://www.jonof.id.au/kenutils)
- `jpegtran` - [homepage](http://jpegclub.org/jpegtran/)
- `jpegoptim` - [homepage](http://freecode.com/projects/jpegoptim)
- `gifsicle` - [homepage](http://www.lcdf.org/gifsicle/)

You can obtain concrete optimizer by passing his name to `ImageOptimizer\OptimizerFactory`::`get` method:

```
    //default optimizer is `smart`
    $optimizer = $factory->get();

    //png optimizer
    $pngOptimizer = $factory->get('png');

    //jpegoptim optimizer etc.
    $jpgOptimizer = $factory->get('jpegoptim');
```

License
=======

[](#license)

**MIT**

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 57.9% of commits — single point of failure

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.

###  Release Activity

Cadence

Every ~99 days

Recently: every ~94 days

Total

10

Last Release

3453d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1434156?v=4)[Sebastian Luckos](/maintainers/kirapwn)[@kirapwn](https://github.com/kirapwn)

---

Top Contributors

[![psliwa](https://avatars.githubusercontent.com/u/438063?v=4)](https://github.com/psliwa "psliwa (11 commits)")[![kirapwn](https://avatars.githubusercontent.com/u/1434156?v=4)](https://github.com/kirapwn "kirapwn (5 commits)")[![SamarRizvi](https://avatars.githubusercontent.com/u/1614414?v=4)](https://github.com/SamarRizvi "SamarRizvi (2 commits)")[![lkorth](https://avatars.githubusercontent.com/u/1163999?v=4)](https://github.com/lkorth "lkorth (1 commits)")

---

Tags

imagecompressionimage-optimizeroptimizationoptipngjpegoptim

### Embed Badge

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

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

###  Alternatives

[ps/image-optimizer

Image optimization / compression library. This library is able to optimize png, jpg and gif files in very easy and handy way. It uses optipng, pngquant, pngcrush, pngout, gifsicle, jpegoptim and jpegtran tools.

9151.7M25](/packages/ps-image-optimizer)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.6k38.2k](/packages/matomo-matomo)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M723](/packages/sylius-sylius)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k13](/packages/tempest-framework)[phpbench/phpbench

PHP Benchmarking Framework

2.0k14.6M821](/packages/phpbench-phpbench)

PHPackages © 2026

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