Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Image Laravel Package

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.

View on GitHub
Deep Wiki
Context7

PHP Image Processing

Frequently asked questions about Image
How do I install Intervention Image in a Laravel project?
Run `composer require intervention/image` to install. Laravel’s service container auto-discovers the package, but register a custom `ImageManager` binding in `AppServiceProvider` to enforce consistent driver/configuration. Example: `$this->app->singleton('image.manager', fn() => new ImageManager(['driver' => config('image.driver')]));`
Which Laravel versions does Intervention Image support?
Intervention Image v4.x requires Laravel 8.0+ and PHP 8.3+. For older Laravel versions (e.g., 7.x), use v3.x. Check compatibility in the [README](https://github.com/Intervention/image#requirements) or run `composer why-not intervention/image:^4.0` for version conflicts.
How do I switch between GD and Imagick drivers in Laravel?
Configure the driver in `config/image.php` (e.g., `'driver' => env('IMAGE_DRIVER', 'gd')`). Use Laravel’s environment helpers to dynamically switch: `app()->environment('production') ? 'imagick' : 'gd'`. Imagick requires the `php-imagick` extension; install it via `pecl install imagick` or Docker.
Can I use Intervention Image with Laravel queues for background processing?
Yes. Dispatch image-processing jobs with `dispatch(new ProcessImage($imagePath, $resize))`. Use `bus:work` to process jobs in the background. For memory-heavy tasks, optimize with `EncoderOptions` (e.g., `->encode('jpg', 80)`) or chunk large images.
How do I validate image dimensions or file types in Laravel forms?
Use Laravel’s validation rules with Intervention’s `ImageRule`. Example: `'image' => ['required', 'image', new ImageRule(['min_width' => 100, 'max_height' => 1000])]`. Combine with `mimes:jpeg,png` for file-type checks.
What’s the best driver for production: GD or Imagick?
Use **Imagick** for advanced features (e.g., WebP, transparency) and better performance. **GD** is lighter but lacks some formats. Benchmark with `php artisan tinker` and `microtime(true)` before/after processing. For shared hosting, GD is often the only option.
How do I test Intervention Image in Laravel’s unit tests?
Mock `ImageManager` with Laravel’s `Mockery` or use `Storage::fake()` for file operations. Example: `$this->app->instance('image.manager', Mockery::mock('ImageManager'));`. Avoid real file I/O in tests to keep them fast and isolated.
Can I use Intervention Image with Laravel’s Storage facade (e.g., S3)?
Yes. Use `Storage::disk('s3')->put()` to save processed images. For S3, ensure the `league/flysystem-aws-s3-v3` package is installed. Example: `Image::make($file)->resize()->save(storage_path('app/public/thumb.jpg'));` works for local storage too.
How do I handle failed image jobs in Laravel queues?
Failed jobs trigger Laravel’s `FailedJob` event. Log errors with `report()` in your job’s `handle()` method. For retries, configure `maxAttempts` in the job class. Use dead-letter queues (e.g., `queue:failed`) to inspect failed jobs via `php artisan queue:failed-table`.
Are there alternatives to Intervention Image for Laravel?
Yes. For simpler needs, consider **Laravel’s built-in `Image` helper** (limited). For advanced use cases, **Spatie’s `laravel-image-optimization`** (lossless optimization) or **Laravel Media Library** (file management + images) are alternatives. Intervention Image stands out for its fluent API and driver flexibility.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony