On-the-fly image renditions for Laravel: presets, crops, formats and responsive variants, rendered once and served behind a CDN.
This is the
v2.xbranch, where 2.0 is developed, and the default branch. 2.0 is released as alphas (composer require folklore/laravel-image:^2.0@alpha, PHP 8.3+ and Laravel 12+); an alpha can break the previous one, so read the CHANGELOG before you update. 1.x is maintained onv1.x:composer require folklore/laravel-image:^1.1.
2.0 is built on Intervention Image 4, with libvips when available:
Image::for($media)->preset('card')->url();
Image::for('uploads/photo.jpg')->width(800)->ratio('16:9')->avif()->url();
Image::for($media)->variants('card'); // width, height and URL of each variant, for APIsIn the alphas today:
- Presets and canonical specs, in versioned URLs that change when a preset or an original changes.
- Secure by default: opt-in routes (
Route::image()), presets or signed URLs only, enforced limits, private images through expiring URLs. - Derivatives rendered once with libvips, Imagick or GD, stored on any Laravel disk with a lock per variant, served with long-lived caching headers behind a CDN.
- Sources resolved from disks, and from media ids with
laravel-mediatheque2'smediaresolver. ImageVariantResource,Image::fake()andimage:doctor.
Upgrading from 1.x: 1.x URLs keep working through Route::imageLegacy(), and a compatibility layer keeps the 1.x API working, deprecated, until 3.0. php artisan image:upgrade --check lists what a project uses; docs/upgrade.md has the steps.
Planned (roadmap): focal point and non-destructive edits (transform), channel presets, responsive images with srcset() and <x-image>, more operations, and the Rector rules of the upgrade.
The guides of the alpha are in docs/guides/: getting started, presets, URLs and signatures and delivery behind a CDN.
The plan is in docs/: the architecture, the decisions, the roadmap and the upgrade guide. #3 is the index of the plan and tracks 1.x.
See CONTRIBUTING.md for the workflow, and SECURITY.md to report a vulnerability privately.
MIT. See LICENSE.md.