Download the PHP package laravel-enso/imagetransformer without Composer
On this page you can find all versions of the php package laravel-enso/imagetransformer. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download laravel-enso/imagetransformer
More information about laravel-enso/imagetransformer
Files in laravel-enso/imagetransformer
Package imagetransformer
Short Description Image transformer dependency for Laravel Enso
License MIT
Homepage https://github.com/laravel-enso/image-transformer
Informations about the package imagetransformer
Image Transformer
Description
Image Transformer provides a small service for validating, resizing, and optimizing uploaded images.
It uses Laravel's image service, backed by 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.
Installation
Install the package:
The package requires Laravel 13.20 or newer and relies on:
- Laravel's image service and
intervention/image4 for reading and resizing images spatie/laravel-image-optimizerfor optimization
To use resizing, the runtime must have at least one supported image extension installed:
gdimagick
Features
- Validates uploaded files before transformation.
- Supports
png,jpeg,gif, andwebpimages. - Optimizes images in place through Spatie's optimizer chain.
- Resizes images proportionally by width, by height, or by both through
resize(). - Prevents upsizing by only resizing when the original image is larger than the requested dimension.
- Upscales images proportionally to minimum dimensions through
upscaleTo(). - Encodes transformed images as JPEG bytes through
toJpeg(). - Saves downscale transformations back to the original file path while keeping upscale and encoding operations in memory.
- Keeps chained width and height transformations in one processing pipeline to avoid intermediate re-encoding.
- Preserves the previous default encoding quality for in-place transformations.
Usage
Create a transformer from an uploaded file:
Optimize the original file:
Resize proportionally to a maximum width:
Resize proportionally to a maximum height:
Apply both constraints in sequence:
Upscale proportionally until both minimum dimensions are reached, then encode the result as JPEG without modifying the original file:
::: 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().
upscaleTo() and toJpeg() operate in memory and do not modify the original file.
:::
API
Service
LaravelEnso\ImageTransformer\Services\ImageTransformer
Constructor:
__construct(File $file)
Public methods:
optimize(): selfresize(int $width, int $height): selfupscaleTo(int $width, int $height): selftoJpeg(int $quality = 85): stringwidth(int $width): selfheight(int $height): self
Supported Mime Types
The service accepts:
image/pngimage/jpegimage/gifimage/webp
Exceptions
The package exposes:
LaravelEnso\ImageTransformer\Exceptions\FileLaravelEnso\ImageTransformer\Exceptions\Dependency
Scenarios covered:
- invalid uploaded file
- unsupported mime type
- missing
gd/imagickextension when resizing
Depends On
Required Enso packages:
External dependencies:
Contributions
are welcome. Pull requests are great, but issues are good too.
Thank you to all the people who already contributed to Enso!
All versions of imagetransformer with dependencies
laravel/framework Version ^13.20
laravel-enso/helpers Version ^4.0
php Version ^8.3
spatie/laravel-image-optimizer Version ^1.6