spatie/image
Expressive PHP image manipulation with a fluent API. Resize, crop, rotate, sharpen, adjust brightness/contrast, apply filters, set quality and orientation, and convert formats. Load, chain operations, and save to a new file or overwrite.
Image::load()->width()->height()->save()) aligns well with Laravel’s Eloquent and Blade conventions, reducing cognitive load for developers familiar with Laravel’s syntax.Storage facade) and queue systems for async processing (e.g., resizing images during uploads).image.resized) for logging, analytics, or notifications, leveraging Laravel’s event system.spatie/image) with no complex setup beyond enabling PHP extensions (e.g., exif, gd, imagick).Storage facade.Image::load()->resize()->save() dispatched via dispatch()), improving performance for high-traffic apps.exif extension). Risk in environments where extensions are disabled.Imagick in staging, GD in production)?Storage facade to abstract local/S3 paths (e.g., Storage::disk('s3')->put()).dispatch() for async processing (e.g., ResizeImageJob).Illuminate\Support\Facades\Validator to enforce image size/format rules.ImageResized) to notify other services.php-imagick (preferred for production).php-vips).spatie/image + srcset in Blade).exec('convert')) with spatie/image.spatie/image jobs in app/Jobs).Log facade or third-party tools (e.g., Sentry).spatie/image (similar API).composer require spatie/image.gd, exif, optionally imagick/vips)..env (if needed):
SPATIE_IMAGE_DRIVER=gd
config/filesystems.php.max:2048 in Form Requests).ResizeImageJob) and dispatch it from controllers/upload handlers.spatie/image for breaking changes (e.g., PHP 8.5 support in v3.8.7).imagick) as needed for new features.CouldNotLoadImage, CouldNotSaveImage) with context (e.g., input path, driver).try {
Image::load($path)->resize()->save();
} catch (\Exception $e) {
Log::error("Image processing failed: {$e->getMessage()}", ['path' => $path, 'driver' => config('image.driver')]);
}
phpinfo()).getimagesize()).dd(Image::load($path)->debug()) to inspect image metadata.SPATIE_IMAGE_DEBUG=true in .env for verbose logs.chunk() to process large datasets (e.g., bulk image resizing).Cache::remember() or Redis) to avoid reprocessing.memory_limit in php.ini) for large images.Vips driver for memory-intensive tasks (if available).images table for reference.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| PHP extension missing | Image processing fails silently | Validate extensions in bootstrap/app.php; fallback to GD. |
How can I help you explore Laravel packages today?