php-collective / file-storage-image-processor
File Storage Image Processor
Installs: 4 404
Dependents: 3
Suggesters: 2
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 1
pkg:composer/php-collective/file-storage-image-processor
Requires
- php: >=8.1
- ext-json: *
- intervention/image: ^3.2.0
- spatie/image-optimizer: ^1.2.0
Requires (Dev)
- php-collective/code-sniffer: ^0.4.1
- php-collective/file-storage: ^1.0.0
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.3 || ^11.5 || ^12.3
This package is auto-updated.
Last update: 2025-11-10 22:13:01 UTC
README
Image Processing for the File Storage Library.
Built on top of Intervention Image v3.
Features
- Manipulates images and produces variants of the original image and stores them
- Supports multiple image operations: resize, scale, crop, rotate, flip, sharpen, and more
- Optimizes image file size using spatie/image-optimizer
- Works with League Flysystem for flexible storage backends
- Fluent API for chaining image operations
Requirements
- PHP 8.1 or higher
- GD or Imagick extension
- Intervention Image v3
Installation
composer require php-collective/file-storage-image-processor
Quick Example
use PhpCollective\Infrastructure\Storage\Processor\Image\ImageVariantCollection; $collection = ImageVariantCollection::create(); // Create a thumbnail with aspect ratio preserved $collection->addNew('thumbnail') ->scale(300, 300) ->optimize(); // Create a specific-sized avatar $collection->addNew('avatar') ->cover(150, 150) ->optimize(); $file = $file->withVariants($collection->toArray()); $file = $imageProcessor->process($file);
Documentation
Please start by reading the documentation in the docs/ directory:
- Installation & Setup
- Processing Images
- Available Operations - Complete reference of all image operations
Upgrade from v2
This package uses Intervention Image v3, which has breaking changes from v2:
ImageManagernow requires a Driver instance instead of array configuration- The
resize()method no longer has anaspectRatioparameter - Use
scale()for aspect ratio preservation (recommended for most cases) - Use
resize()only when you need exact dimensions (may distort image)
See the Available Operations documentation for detailed examples.