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(10mo ago)22.0kMITPHPPHP ^8.1

Since Aug 10Pushed 10mo 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 today

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

35

—

LowBetter than 77% of packages

Maintenance54

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

322d 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.4k60.7M188](/packages/spatie-image)[spatie/browsershot

Convert a webpage to an image or pdf using headless Chrome

5.2k36.7M156](/packages/spatie-browsershot)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[spatie/laravel-health

Monitor the health of a Laravel application

87512.0M165](/packages/spatie-laravel-health)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[intervention/image-laravel

Laravel Integration of Intervention Image

1588.9M181](/packages/intervention-image-laravel)

PHPackages © 2026

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