intervention/image
Intervention Image is a PHP image handling and manipulation library for Laravel and other frameworks. It provides a fluent API for resizing, cropping, encoding, watermarking, and optimizing images, with drivers for GD and Imagick and easy integration via service providers.
$image->resize()->watermark()) aligns seamlessly with Laravel’s Eloquent and Blade paradigms, reducing cognitive load for developers familiar with Laravel’s conventions.Storage::disk()) for storage-agnostic image processing.Response::stream() for dynamic image generation).composer require intervention/image) with zero Laravel-specific configuration (unlike packages requiring service providers).tests/Feature/ImageProcessingTest.php.php-imagick extension (not always pre-installed).vips extension (less common in shared hosting).->encode('gif', ['loop' => 0])).Color class changes), but Laravel’s dependency management (e.g., ^4.0) mitigates this.stream_get_contents() optimizations.Storage::disk('public')->put() for saving processed images.Request::validate(['image' => 'image|max:10240']).return Response::stream().ImageProcessingJob (e.g., for PDF-to-image conversion).wire:model + client-side processing.@ApiProperty.composer.json and publish config (if needed).app/Services/ImageProcessor.php) to wrap Intervention/Image for consistency.class ImageProcessor {
public function __call($method, $args) {
return app(ImageManager::class)->gd()->$method(...$args);
}
}
config/image.php.ImageProcessor to support queueable jobs and S3 streams.Cache-Control: max-age=31536000) for static assets.pecl install gd if missing).pecl install imagick).pecl install vips).| Priority | Task | Dependencies |
|---|---|---|
| 1 | Core setup + basic ops | Laravel, PHP GD |
| 2 | Driver benchmarking | Imagick/libvips extensions |
| 3 | Async job integration | Laravel Queues |
| 4 | S3/Cloud Storage support | AWS SDK or Laravel Filesystem |
| 5 | Visual regression testing | Pest + imagehash libraries |
^ constraints auto-update minor versions.laravel tag.Color class) require migration scripts.phpinfo() for enabled extensions (gd, imagick).ini_set('memory_limit', '512M') for large images.storage/app/public) are writable.tests/Feature/ as a reference for Laravel integrations.intervention/image + laravel.laravel-queue:work).memory_limit for batch jobs (e.g., php artisan queue:work --memory=1G).imagick for high-res images (e.g., medical imaging).k6 to validate driver performance under load.| Scenario | Impact | Mitigation |
|---|---|---|
| Driver extension missing | Processing fails silently | Fallback to GD or throw DriverNotFoundException. |
| Memory exhaustion | Job crashes | Use libvips or chunk processing. |
| Corrupted input | InvalidImageException | Validate with `get |
How can I help you explore Laravel packages today?