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

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.

View on GitHub
Deep Wiki
Context7

Manipulate images with an expressive API

Frequently asked questions about Image
How do I install spatie/image in a Laravel project?
Run `composer require spatie/image` in your project directory. The package requires PHP 8.0+ and one of the extensions: GD, Imagick, or VIPS. No additional Laravel-specific setup is needed beyond requiring the package.
Which Laravel versions does spatie/image support?
The package is framework-agnostic but works seamlessly with Laravel 8.x, 9.x, and 10.x. It doesn’t rely on Laravel’s core, so it won’t conflict with newer versions unless you’re using Laravel-specific integrations like Storage facade.
Can I use spatie/image for async image resizing in Laravel?
Yes. Chain operations with `save()` to a temporary path, then dispatch a job (e.g., `ImageResizeJob`) to process and store the final image. Use Laravel’s queue system (`@queue` or `dispatch()`) for background processing.
What’s the difference between GD, Imagick, and VIPS drivers?
GD is lightweight but lacks advanced features like AVIF/HEIC support. Imagick offers superior performance and format support but requires system dependencies. VIPS is memory-efficient for large images but less common. Choose based on your needs: GD for simplicity, Imagick for power, VIPS for scalability.
How do I handle image orientation (e.g., EXIF rotation) with this package?
Use the `orientation()` method to auto-correct rotation based on EXIF data. Ensure the `exif` PHP extension is enabled in your environment. For shared hosting, you may need to manually rotate images or use a fallback like `->rotate(90)` if EXIF isn’t available.
Can I integrate spatie/image with Laravel’s Storage facade?
Absolutely. Load images from `Storage::disk('public')->path($file)` and save processed files back to the same or a different disk. Example: `Image::load(storage_path('app/public/'.$file))->resize()->save(storage_path('app/public/thumbs/'.$file)).`
What’s the best way to validate images before processing?
Use Laravel’s validation rules like `mimes:jpeg,png,gif` and `max:5000` to check file types and sizes. For advanced checks (e.g., dimensions), use `getimagesize()` or libraries like `spatie/laravel-medialibrary` for model-based validation.
How do I migrate from Intervention Image to spatie/image?
Replace `Image::make($path)` with `Image::load($path)` and update method names (e.g., `resize()` → `width($width)->height($height)`). The API is similar but more fluent. Test edge cases like filters (`sepia()` vs. `filter(Filter::Sepia)`) and fallbacks.
What should I do if Imagick/GD isn’t available in production?
Configure a fallback driver in your `config/filesystems.php` or use a try-catch block to degrade gracefully. For example, log a warning and serve a placeholder if the primary driver fails. Alternatively, use `->save()` with a lower-quality GD fallback.
How can I test image manipulations in Laravel?
Mock the `Image` facade in PHPUnit or use temporary files in `storage/app/test-images`. Compare outputs with `file_get_contents()` or visual regression tools like `php-image-magick-comparison`. Test edge cases like corrupt files, transparency, and extreme dimensions.
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