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 Laravel and set up a default driver (GD/Imagick)?
Run `composer require intervention/image` to install. Configure the default driver in `config/filesystems.php` under `disks` or use the service provider in `config/app.php`. For Imagick, ensure the PHP extension is installed (`php -m | grep imagick`). The package auto-detects drivers but defaults to GD if none are configured.
Does Intervention Image support async processing for large images in Laravel queues?
Yes, wrap heavy operations in a job (e.g., `ImageProcessJob`) and dispatch it via Laravel’s queue system. Use `Image::make()->...->save()` inside the job’s `handle()` method. For memory-intensive tasks, process images in chunks or leverage Redis caching for thumbnails.
What Laravel versions does Intervention Image officially support, and are there breaking changes in v4?
Intervention Image v4 requires Laravel 5.5+. No major breaking changes exist for core functionality, but new exception type hints (e.g., `InvalidArgumentException`) may require updates to error-handling logic. Facade syntax (`Image::make()`) and service container integration remain unchanged.
How do I add a watermark or text overlay to an image in Laravel using this package?
Use the fluent API: `$img = Image::make('path/to/image.jpg')->text('Watermark', 10, 10, function($color) { $color->size(12); })->save();` For watermarks, chain `insert()` with a semi-transparent PNG. Ensure the text or watermark layer is added *before* resizing to maintain proportions.
Which image drivers (GD/Imagick/libvips) should I choose for Laravel production, and how do I benchmark them?
Imagick offers superior performance and format support (e.g., WebP/AVIF) but requires system dependencies. GD is lighter but lacks advanced features. Benchmark by processing identical images with both drivers and comparing execution time (`microtime(true)`). Use `Image::driver('imagick')` to force a driver for testing.
Can I use Intervention Image to generate dynamic images for API responses (e.g., QR codes, charts)?
Yes, dynamically generate images in API routes or controllers. For example, create a QR code: `$img = Image::make()->text('Dynamic Content', 0, 0)->encode('png'); return response($img)->header('Content-Type', 'image/png');` Cache responses with Redis or Laravel’s cache system for repeated requests.
How do I handle memory limits when processing large images (e.g., 10MB+) in Laravel?
Increase PHP’s `memory_limit` in `php.ini` or use `ini_set('memory_limit', '512M')` in your script. For very large files, process in chunks (e.g., resize to a smaller canvas first) or use `libvips` (if available), which handles memory more efficiently than GD/Imagick. Monitor with `memory_get_usage()`.
Are there alternatives to Intervention Image for Laravel, and when should I consider them?
Alternatives include `spatie/image-optimizer` (for optimization) or `league/glide` (for dynamic URLs). Use Glide if you need signed URLs or CDN-friendly image URLs. Intervention Image is ideal for direct file manipulation and fluent syntax, while Glide excels in API-driven workflows. Choose based on whether you need server-side processing (Intervention) or client-side delivery (Glide).
How do I test Intervention Image in Laravel unit tests, especially with mocked drivers?
Mock the `Image` facade using Laravel’s `MockFacade` or `createMock()`. Test transformations with assertions like `assertTrue($img->resize(100, 100)->save());`. For driver-specific tests, use `Image::driver('imagick')` and verify exceptions with the new type hints (e.g., `assertInstanceOf(InvalidArgumentException::class, ...)`). Test edge cases like corrupt files or unsupported formats.
What’s the best way to cache thumbnails in Laravel to reduce processing time?
Store generated thumbnails in Laravel’s filesystem (e.g., `storage/app/public/thumbs/`) and use the `Filesystem` facade to check existence before processing. For dynamic URLs, combine with `league/glide` or cache responses in Redis with a key like `thumb:{filename}:{width}x{height}`. Set cache TTLs based on image volatility (e.g., 24 hours for static assets).
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai