Download the PHP package sandstorm/laravel-imagor without Composer
On this page you can find all versions of the php package sandstorm/laravel-imagor. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sandstorm/laravel-imagor
More information about sandstorm/laravel-imagor
Files in sandstorm/laravel-imagor
Package laravel-imagor
Short Description Laravel integration for Imagor
License MIT
Homepage https://github.com/sandstorm/laravel-imagor
Informations about the package laravel-imagor
Laravel integration for Imagor
A comprehensive Laravel package for Imagor integration. Generate optimized, signed image URLs with fluent API including resizing, quality control, visual effects, and advanced processing options. Originally forked from https://github.com/imsus/laravel-imgproxy, which deserves most credit :)
- Laravel integration for Imagor
- Features
- Installation
- Basic Usage
- Accessing the Imagor object
- Resizing & Cropping
- Quality & Format Control
- Visual Effects
- Image Transformations
- Laravel Integration
- Livewire: Display temporary uploaded files
- Display images from the public storage
- Upload images in Filament Forms
- Blade Directives
- API Reference
- Available Methods
- Supported Formats
- Image Processing Recipes
- Photo Enhancement
- E-commerce Optimization
- Development Setup
- Unit & Integration Tests
- Interactive Testing with Workbench
- Troubleshooting
- File Sizes
- Changelog
- Credits
- License
Features
- ๐ Fluent API - Clean, chainable method syntax
- ๐ Secure URLs - HMAC signed URLs with configurable keys
- ๐จ Visual Effects - Blur, sharpen, brightness, contrast, saturation adjustments
- โก Quality Control - Fine-tune compression and output formats
- ๐ง Flexible Resizing - Multiple resize modes with smart cropping
- ๐งฉ Laravel Integration - Service provider, facade, and helper function
- โ Type Safe - PHP 8.2+ with comprehensive validation
- ๐งช Well Tested - Comprehensive test suite with workbench integration
Installation
You can install the package via composer:
You can publish the config file with:
To set up Imagor via docker-compose.yaml, use the following snippet:
Finally, can call the URL /__imagor-configtest to check if Imagor is configured correctly. This example copies some pre-defined images to the storage folder and then loads it through Imagor to check if everything is wired correctly.
Basic Usage
NOTE: the image URL to be processed is passed at the END of the chain, to be able to use the same instance of the
Imagor class for multiple image processing operations:
NOTE: the Imagor class is immutable, so you always need to assign the result of a method call to a variable:
Accessing the Imagor object
The following methods exist for accessing the Imagor object:
- inject
Sandstorm\LaravelImagor\ImagorFactory, and call->new()to get a new instance of theImagorclass - inject
Sandstorm\LaravelImagor\Imagor- you'll get a new instance of theImagorclass every time - use the
imagor()helper function
If in doubt, use one of the injections.
Resizing & Cropping
Quality & Format Control
Visual Effects
Image Transformations
Accessing the image binary data
If, for some reason, you need to access the image binary data, you can use ->imageBinaryDataFor() instead of
->uriFor():
Laravel Integration
Livewire: Display temporary uploaded files
before:
after:
Display images from the public storage
before:
after:
TODO: see if we can make this work a bit simpler :)
Upload images in Filament Forms
before:
after:
Blade Directives
Create custom Blade directives for common use cases:
API Reference
Available Methods
| Method | Parameters | Description |
|---|---|---|
resize(int $width, int $height) |
Width, height in pixels | Set image dimensions |
crop(int $a, int $b, int $c, int $d) |
Coordinates | Manual crop (left, top, right, bottom) |
fitIn() |
- | Fit image within dimensions |
stretch() |
- | Force resize without aspect ratio |
smart() |
- | Smart focal point detection |
trim() |
- | Remove surrounding whitespace |
flipHorizontally() |
- | Flip image horizontally |
flipVertically() |
- | Flip image vertically |
padding(int $left, int $top, int $right, int $bottom) |
Padding values | Add padding around image |
hAlign(string $align) |
'left', 'right', 'center' | Horizontal alignment |
vAlign(string $align) |
'top', 'bottom', 'middle' | Vertical alignment |
quality(int $quality) |
0-100 | Set JPEG quality |
format(string $format) |
Format string | Set output format |
blur(float $sigma) |
โฅ0.0 | Apply blur effect |
sharpen(float $sigma) |
โฅ0.0 | Apply sharpen effect |
brightness(int $amount) |
-255 to 255 | Adjust brightness |
contrast(int $amount) |
Percentage | Adjust contrast |
saturation(int $amount) |
Percentage | Adjust saturation |
addFilter(string $name, ...$args) |
Filter name and args | Add custom filter |
uriFor(string $sourceImage) |
Image URL | Generate final URL |
Supported Formats
jpeg- JPEG formatpng- PNG formatgif- GIF formatwebp- WebP formatavif- AVIF formatjxl- JPEG XL formattiff- TIFF formatjp2- JPEG 2000 format
Image Processing Recipes
Photo Enhancement
E-commerce Optimization
Development Setup
Unit & Integration Tests
Interactive Testing with Workbench
The package includes a comprehensive workbench environment for interactive testing:
Now access the Visual Test Suite at http://localhost:8000/imgproxy-visual-test
Troubleshooting
Problem: Getting "unsafe" URLs instead of signed URLs
Solution: Ensure IMAGOR_SECRET is set in your .env file.
Problem: Images not loading/404 errors Solutions:
- Verify Imagor server is running at the configured base URL
- Check source image URLs are accessible
- Ensure Imagor server can reach source URLs (firewall/network issues)
Problem: Poor image quality
Solutions:
- Increase quality setting:
->quality(90) - Use appropriate output format:
->format('webp') - Avoid excessive sharpening:
->sharpen(1.0)instead of higher values
File Sizes
imagor_docker, with VIPS_MOZJPEG: 0; or shumc/imagor:latest
(no mozjpeg)
imagor_docker, with VIPS_MOZJPEG: 1
f.e. the image ghcr.io/cshum/imagor-mozjpeg:docker-variants from https://github.com/cshum/imagor/issues/456#issuecomment-3341418493
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
- Imam Susanto for the original package
- Sandstorm Media for the Imagor fork
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of laravel-imagor with dependencies
illuminate/contracts Version ^10.0|^11.0|^12.0|^13.0
spatie/laravel-package-tools Version ^1.19