Image transformer dependency for Laravel Enso
laravel-enso/image-transformer is a Laravel package for image transformer dependency for laravel enso.
It currently has 6 GitHub stars and 51.610 downloads on Packagist (latest version 2.5.4).
Install it with composer require laravel-enso/image-transformer.
Discover more Laravel packages by laravel-enso
or browse all Laravel packages to compare alternatives.
Last updated
Image Transformer provides a small service for validating, resizing, and optimizing uploaded images.
It wraps Intervention Image for resize operations and Spatie's image optimizer for post-processing, while enforcing a limited set of supported image mime types before any transformation is attempted.
The package is useful in upload flows where images should be normalized before storage, for example avatars, covers, gallery images, or document attachments that need size limits and optimization.
Install the package:
composer require laravel-enso/image-transformer
The package relies on:
intervention/image-laravel for reading and resizing imagesspatie/laravel-image-optimizer for optimizationTo use resizing, the runtime must have at least one supported image extension installed:
gdimagickpng, jpeg, gif, and webp images.resize().Create a transformer from an uploaded file:
use LaravelEnso\ImageTransformer\Services\ImageTransformer;
$transformer = new ImageTransformer($file);
Optimize the original file:
$transformer->optimize();
Resize proportionally to a maximum width:
$transformer->width(512);
Resize proportionally to a maximum height:
$transformer->height(512);
Apply both constraints in sequence:
$transformer->resize(1024, 768);
::: tip Tip The transformer edits the original file in place.
If you need to preserve the original upload, copy or move it before calling optimize(), width(), height(), or resize().
:::
LaravelEnso\ImageTransformer\Services\ImageTransformer
Constructor:
__construct(File $file)Public methods:
optimize(): selfresize(int $width, int $height): selfwidth(int $width): selfheight(int $height): selfThe service accepts:
image/pngimage/jpegimage/gifimage/webpThe package exposes:
LaravelEnso\ImageTransformer\Exceptions\FileLaravelEnso\ImageTransformer\Exceptions\DependencyScenarios covered:
gd / imagick extension when resizingRequired Enso packages:
External dependencies:
are welcome. Pull requests are great, but issues are good too.
Thank you to all the people who already contributed to Enso!