PHPackages                             php-collective/file-storage-image-processor - 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. [File &amp; Storage](/categories/file-storage)
4. /
5. php-collective/file-storage-image-processor

ActiveLibrary[File &amp; Storage](/categories/file-storage)

php-collective/file-storage-image-processor
===========================================

File Storage Image Processor

2.0.0(2mo ago)011.5k↑567%1[1 issues](https://github.com/php-collective/file-storage-image-processor/issues)2MITPHPPHP &gt;=8.3CI passing

Since Dec 27Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/php-collective/file-storage-image-processor)[ Packagist](https://packagist.org/packages/php-collective/file-storage-image-processor)[ RSS](/packages/php-collective-file-storage-image-processor/feed)WikiDiscussions master Synced yesterday

READMEChangelog (4)Dependencies (12)Versions (17)Used By (2)

File Storage Image Processing
=============================

[](#file-storage-image-processing)

[![CI](https://camo.githubusercontent.com/368a1ea77cf09c806cff05e5fb975f90a49450b3c46c9971e1237746613c8af9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7068702d636f6c6c6563746976652f66696c652d73746f726167652d696d6167652d70726f636573736f722f63692e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/php-collective/file-storage-image-processor/actions)[![Coverage](https://camo.githubusercontent.com/62d32e0a64480d001940af5b587d47c9c9143e748779f63fc74a49d76b83b6c6/68747470733a2f2f636f6465636f762e696f2f67682f7068702d636f6c6c6563746976652f66696c652d73746f726167652d696d6167652d70726f636573736f722f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/php-collective/file-storage-image-processor)[![Latest Stable Version](https://camo.githubusercontent.com/8ab8af8f30934ffa27a69ac1f43256d04428936cdf3c3d5a822fae357c92afa3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068702d636f6c6c6563746976652f66696c652d73746f726167652d696d6167652d70726f636573736f723f7374796c653d666c61742d737175617265)](https://packagist.org/packages/php-collective/file-storage-image-processor)[![Total Downloads](https://camo.githubusercontent.com/636b54a51f692d531516e75195bf62a3c8ef41f1a9bc49318e157aa5fd9880b2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7068702d636f6c6c6563746976652f66696c652d73746f726167652d696d6167652d70726f636573736f723f7374796c653d666c61742d737175617265)](https://packagist.org/packages/php-collective/file-storage-image-processor)[![PHPStan](https://camo.githubusercontent.com/fff00cebb924e124a7335e6bd8ca8f8cf38869463c1654eff45d0939f1f21c57/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230382d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](https://phpstan.org/)[![PHP Version](https://camo.githubusercontent.com/41fc33e77fa34929fcb9f3d5b8077022925bfcf89e20130ead48adbc92fbe04e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e332d3838393242462e7376673f7374796c653d666c61742d737175617265)](https://php.net)[![Software License](https://camo.githubusercontent.com/6c711032aff1ca0eb6b211aa6cb3649ce7fd64a7714e1181d4bb457f9680e7cf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

Image Processing for the [File Storage Library](https://github.com/php-collective/file-storage).

Built on top of [Intervention Image v4](https://image.intervention.io/v4).

Features
--------

[](#features)

- Generates and stores variants of an uploaded image (thumbnails, avatars, hero crops, …)
- 24+ first-class image operations: resize, scale, cover, crop, rotate, flip, sharpen, orient (EXIF auto-rotate), brightness, contrast, grayscale, colorize, blur, pixelate, trim, resizeCanvas, padding, place (watermark), convert (format swap), …
- Per-format encoder quality, EXIF/metadata strip toggle, ICC color-profile preservation
- Pluggable operation registry — add custom operations without forking
- Optional file-size optimization via [spatie/image-optimizer](https://github.com/spatie/image-optimizer)
- Works with League Flysystem for flexible storage backends
- Fluent API for chaining operations, including repeating the same operation type multiple times

Requirements
------------

[](#requirements)

- GD or Imagick extension
- [Intervention Image v4](https://image.intervention.io/v4)

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

[](#installation)

```
composer require php-collective/file-storage-image-processor
```

Quick Example
-------------

[](#quick-example)

```
use PhpCollective\Infrastructure\Storage\Processor\Image\Driver;
use PhpCollective\Infrastructure\Storage\Processor\Image\Format;
use PhpCollective\Infrastructure\Storage\Processor\Image\ImageProcessor;
use PhpCollective\Infrastructure\Storage\Processor\Image\ImageVariantCollection;
use PhpCollective\Infrastructure\Storage\Processor\Image\Position;

// Driver::Auto picks Imagick when the extension is loaded and falls
// back to GD; use Driver::Gd or Driver::Imagick to choose explicitly.
$imageProcessor = ImageProcessor::create(Driver::Auto, $fileStorage, $pathBuilder);

$collection = ImageVariantCollection::create();

// Create a thumbnail with aspect ratio preserved
$collection->addNew('thumbnail')
    ->scale(300, 300)
    ->optimize();

// Create an avatar that fills exact dimensions
$collection->addNew('avatar')
    ->cover(150, 150, Position::TopCenter)
    ->optimize();

// Re-encode a JPEG source as WebP — Format enum or string both work
$collection->addNew('webp')
    ->scale(800, 600)
    ->convert(Format::Webp);

// Repeat the same operation type without losing earlier steps
$collection->addNew('effects')
    ->blur(1)
    ->blur(6);

$file = $file->withVariants($collection->toArray());
$file = $imageProcessor->process($file);
```

### Tuning the encoder

[](#tuning-the-encoder)

```
$imageProcessor
    ->setQuality(['webp' => 80, 'jpg' => 90, 'avif' => 70]) // per-format
    ->setStripExif(true)            // privacy + smaller files (default)
    ->setPreserveProfile(true)      // keep wide-gamut color rendering (default)
    ->setPreserveAnimation(true);   // animated GIF/WebP keep all frames (default)
```

`setPreserveAnimation(false)` flattens animated sources to a single frame — useful for static thumbnail variants or when converting to a non-animated format like JPEG.

### Processing a subset of variants

[](#processing-a-subset-of-variants)

```
// Per-call filter — does not leak into subsequent process() calls.
$file = $imageProcessor->process($file, ['thumbnail']);
```

### Custom operations

[](#custom-operations)

```
use PhpCollective\Infrastructure\Storage\Processor\Image\Operation\Operation;
use PhpCollective\Infrastructure\Storage\Processor\Image\Operation\OperationRegistry;

$registry = OperationRegistry::default()
    ->register('myFilter', static fn (array $args): Operation => new MyFilter(...$args));

$processor = new ImageProcessor($storage, $pathBuilder, $imageManager, urlBuilder: null, operationRegistry: $registry);
```

Repeated operations of the same name are preserved in order when you serialize variants with `toArray()` and rebuild them later with `ImageVariantCollection::fromArray()`.

Documentation
-------------

[](#documentation)

Please start by reading the documentation in the [docs/](/docs/readme.md) directory:

- [Installation &amp; Setup](/docs/Installation-and-Setup.md)
- [Processing Images](/docs/Processing-Images.md)
- [Available Operations](/docs/Available-Operations.md) — complete reference of all image operations

Upgrading from 1.x to 2.x
-------------------------

[](#upgrading-from-1x-to-2x)

This major release migrates to Intervention Image v4 and replaces the stringly-typed dispatcher with a typed Operation class hierarchy. See the [CHANGELOG](/CHANGELOG.md) for the full list; the headline changes:

- **PHP 8.3+** required (was 8.1)
- **Intervention Image v4** required (was v3)
- `processOnlyTheseVariants()` / `processAll()` removed — use the new `process($file, ['thumbnail'])` per-call filter instead
- `Operations::POSITION_*` string constants replaced by the `Position` enum (`Position::Center`, `Position::TopCenter`, …)
- `ImageVariant::FLIP_HORIZONTAL`/`FLIP_VERTICAL` constants replaced by the `FlipDirection` enum
- `Operations` class is gone — operations are now individual classes under `src/Operation/` resolved via `OperationRegistry`
- `flip()` now accepts `FlipDirection|string` (string form still works for config-driven setups)
- `cover()` no longer takes a (always-ignored) `$callback` parameter

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance87

Actively maintained with recent releases

Popularity26

Limited adoption so far

Community18

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 74.2% 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 ~213 days

Total

5

Last Release

65d ago

Major Versions

0.1.0 → 1.0.02025-11-10

v1.x-dev → 2.0.02026-04-29

PHP version history (2 changes)0.1.0PHP &gt;=8.1

2.0.0PHP &gt;=8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/39854?v=4)[Mark Scherer](/maintainers/dereuromark)[@dereuromark](https://github.com/dereuromark)

---

Top Contributors

[![dereuromark](https://avatars.githubusercontent.com/u/39854?v=4)](https://github.com/dereuromark "dereuromark (49 commits)")[![burzum](https://avatars.githubusercontent.com/u/162789?v=4)](https://github.com/burzum "burzum (15 commits)")[![floriankraemer](https://avatars.githubusercontent.com/u/4996022?v=4)](https://github.com/floriankraemer "floriankraemer (2 commits)")

---

Tags

persistenceimage processingfilesstoragemediafile systemagnosticfile storage

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/php-collective-file-storage-image-processor/health.svg)

```
[![Health](https://phpackages.com/badges/php-collective-file-storage-image-processor/health.svg)](https://phpackages.com/packages/php-collective-file-storage-image-processor)
```

###  Alternatives

[league/flysystem

File storage abstraction for PHP

13.6k679.9M2.5k](/packages/league-flysystem)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.7k285.7M1.0k](/packages/league-flysystem-aws-s3-v3)[mostafaznv/larupload

Larupload is a ORM based file uploader for laravel to upload image, video, audio and other known files.

75462.1k6](/packages/mostafaznv-larupload)[sylius/resource-bundle

Resource component for Sylius.

23610.8M235](/packages/sylius-resource-bundle)[code16/sharp

Laravel Content Management Framework

79164.7k8](/packages/code16-sharp)[league/flysystem-async-aws-s3

AsyncAws S3 filesystem adapter for Flysystem.

2812.1M44](/packages/league-flysystem-async-aws-s3)

PHPackages © 2026

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