ellie1337 / laravel-images
Manage & resize images easily
1.0.1
2026-02-16 16:48 UTC
Requires
- php: >=8.1
- illuminate/contracts: ^10.0|^11.0|^12.0
- intervention/image: ^3.11
README
This is a QoL wrapper around intervention/image, with the intent on removing the cognitive
load to create well sized images.
Installation
composer require ellie1337/laravel-images
php artisan vendor:publish --tag=laravel-images
php artisan storage:link
How it works
Super simple way for blades, etc
<img src="{{ \webp('my-file.jpg', height: 100) }}" />
Usage:
webp,png,jpg,aviffunctions are exposed- Accepts as many or as few params as you'd like:
width,height,background,quality,placeholder - Maintains aspect ratio, injects
backgroundinto any additional space - Returns a full URL to pipe into a blade
Elsewhere (or if you prefer a nicer API)
use Ellie1337\LaravelImages\Services\Image;
/** @var Image $image */
$image = app(Image::class);
$image->path('my-file.jpg')
->width(100)
->height(100)
->type('webp')
->url(); // equivalent to \webp('my-file.jpg', width: 100, height: 100);
Cleaning up your images
Sometimes you delete an image, and that's okay!
use Ellie1337\LaravelImages\Services\Image;
/** @var Image $image */
$image = app(Image::class);
$image->delete('my-file.jpg', deleteSource: true);
The delete function will delete all cached variants of the source image. If deleteSource is true, it will also delete
the source image itself.
Hooking into the lifecycle
If you assign an image in a model, eg as a user avatar, you can hook into the deleting method to make life much easier!
use Ellie1337\LaravelImages\Services\Image;
// model
protected static function booted() {
static::deleting(function ($model) {
if ($model->avatar) {
app(Image::class)
->delete($model->avatar, deleteSource: true);
}
})
}
License
This project is licensed under the MIT License.