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

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

componenta/image-compressor
===========================

Image compression helpers for Componenta

v1.0.0(1mo ago)01MITPHPPHP ^8.4

Since Jun 16Pushed 1mo agoCompare

[ Source](https://github.com/componenta/image-compressor)[ Packagist](https://packagist.org/packages/componenta/image-compressor)[ RSS](/packages/componenta-image-compressor/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Componenta Image Compressor
===========================

[](#componenta-image-compressor)

Image compression helpers for Componenta. The package compresses image content without changing its format and selects a concrete compressor by detected MIME type.

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

[](#installation)

```
composer require componenta/image-compressor
```

The package declares `Componenta\Image\ImageCompressorConfigProvider` in `extra.componenta.config-providers`. When `componenta/composer-plugin` is installed, the provider is added to the generated provider list automatically.

The package requires PHP `^8.4`, `ext-gd`, `componenta/config`, `componenta/mimetype-detector`, PSR-11, and PSR-7 streams.

Main API
--------

[](#main-api)

```
use Componenta\Image\ImageCompressionOptions;
use Componenta\Image\ImageCompressor;

if ($compressor->canCompress($source)) {
    $image = $compressor->compress($source, new ImageCompressionOptions(quality: 85));
}
```

`$source` may be a binary string or `StreamInterface`. `CompressedImage` contains `content`, `mimeType`, `extension`, and computed `size`.

Supported Formats
-----------------

[](#supported-formats)

Built-in GD compressors support JPEG, PNG, WebP, and AVIF when the local GD extension supports the target operation.

Configuration
-------------

[](#configuration)

`ImageCompressorConfigProvider` registers:

- `ImageCompressor`
- `GdJpegCompressor`
- `GdPngCompressor`
- `GdWebPCompressor`
- `GdAvifCompressor`

`ImageCompressorFactory` uses `MimeTypeDetectorInterface` from the container when available and falls back to `FinfoDetector`.

Options And Errors
------------------

[](#options-and-errors)

`ImageCompressionOptions::$quality` must be `null` or an integer from `0` to `100`. Invalid quality throws `CompressionException::invalidQuality()`.

`ImageCompressor` throws `CompressionException` when the source type cannot be detected or no compressor supports it.

Extension Points
----------------

[](#extension-points)

Implement `ImageCompressorInterface` and call `ImageCompressor::addCompressor()` to add another compressor.

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance91

Actively maintained with recent releases

Popularity2

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

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

Unknown

Total

1

Last Release

43d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/20490712?v=4)[Andrey Shelamkoff](/maintainers/Shelamkoff)[@Shelamkoff](https://github.com/Shelamkoff)

---

Top Contributors

[![Shelamkoff](https://avatars.githubusercontent.com/u/20490712?v=4)](https://github.com/Shelamkoff "Shelamkoff (1 commits)")

### Embed Badge

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

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

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k17](/packages/tempest-framework)[cakephp/cakephp

The CakePHP framework

8.8k19.5M1.8k](/packages/cakephp-cakephp)[moonshine/moonshine

Laravel administration panel

1.3k253.1k86](/packages/moonshine-moonshine)[bref/bref

Bref is a framework to write and deploy serverless PHP applications on AWS Lambda.

3.4k10.6M68](/packages/bref-bref)[contao/core-bundle

Contao Open Source CMS

1231.6M2.9k](/packages/contao-core-bundle)

PHPackages © 2026

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