PHPackages                             freshleafmedia/image-compression-finder - 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. freshleafmedia/image-compression-finder

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

freshleafmedia/image-compression-finder
=======================================

1.0.2(9mo ago)22.0kMITPHPPHP ^8.1

Since Aug 10Pushed 9mo ago1 watchersCompare

[ Source](https://github.com/freshleafmedia/image-compression-finder)[ Packagist](https://packagist.org/packages/freshleafmedia/image-compression-finder)[ RSS](/packages/freshleafmedia-image-compression-finder/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (4)Used By (0)

Image Compression Finder
========================

[](#image-compression-finder)

Automatic detection of maximum compression without visually changing the image.

Overview
--------

[](#overview)

This is a library which attempts to determine the maximum amount of compression which can be applied to an image while not introducing any visible changes.

The output is an integer between 0 and 100.

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

[](#installation)

```
composer require freshleafmedia/image-compression-finder

```

### DSSIM

[](#dssim)

A working copy of [kornelski/dssim](https://github.com/kornelski/dssim) must be installed.

To install the latest, at time of writing, on Ubuntu the following one-liner can be used:

```
curl -sSL https://github.com/kornelski/dssim/releases/download/3.2.3/dssim_3.2.3_amd64.deb > /tmp/dssim.deb && apt install /tmp/dssim.deb

```

### Imagick/GD

[](#imagickgd)

Either of Imagick or GD extensions are required.

Usage
-----

[](#usage)

```
use FreshleafMedia\ImageCompressionFinder\ImageCompressionFinder;

$quality = ImageCompressionFinder::make()->run('/path/to/image');

$quality; // 66 (0-100)
```

How it works
------------

[](#how-it-works)

The algorithm uses a binary search to repeatedly compress and test an image until the ideal quality is found

1. Compress the image with a quality setting of 60
2. Analyse the new image using DSSIM
3. If the change is within tolerance the quality is halved, if not it is increased by 50% (aka a binary search)
4. Compress the image again with the new quality
5. GOTO 2

Options
-------

[](#options)

There are a couple of configuration options:

```
$quality = ImageCompressionFinder::make()
    ->maxDifference(0.001) // The highest acceptable visual change. 0-∞ where 0 is no change at all
    ->startingQuality(60) // Where to start the search
    ->driver('imagick') // The driver to use to compress images. Eg imagick or gd
    ->run();
```

Tests
-----

[](#tests)

Unit tests can be run via `composer test`

License
-------

[](#license)

See [LICENSE](LICENSE)

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance58

Moderate activity, may be stable

Popularity20

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~2 days

Total

3

Last Release

276d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/10062339?v=4)[Freshleaf Media](/maintainers/freshleafmedia)[@freshleafmedia](https://github.com/freshleafmedia)

---

Top Contributors

[![freshleafmedia](https://avatars.githubusercontent.com/u/10062339?v=4)](https://github.com/freshleafmedia "freshleafmedia (13 commits)")

---

Tags

automationcompressionhacktoberfestimage-compressionimage-processing

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/freshleafmedia-image-compression-finder/health.svg)

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

###  Alternatives

[spatie/image

Manipulate images with an expressive API

1.4k54.4M138](/packages/spatie-image)[bkwld/croppa

Image thumbnail creation through specially formatted URLs for Laravel

510496.0k23](/packages/bkwld-croppa)[ambroisemaupate/intervention-request

A customizable Intervention Image wrapper to use image simple re-sampling features over urls and a configurable cache.

4242.4k2](/packages/ambroisemaupate-intervention-request)[choowx/rasterize-svg

A PHP library for converting SVG to JPEG, PNG, and WEBP

2261.7k](/packages/choowx-rasterize-svg)[finller/laravel-media

A flexible media library for Laravel

472.1k](/packages/finller-laravel-media)[danihidayatx/image-optimizer

Optimize your Filament images before they reach your database. Forked from joshembling/image-optimizer for Filament v4 &amp; v5 support.

254.4k](/packages/danihidayatx-image-optimizer)

PHPackages © 2026

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