Description
Not only Laravel, but a general PHP package: image handling and manipulation library
Intervention Image can be easily integrated into a Laravel application with the official integration package. This package provides a Laravel service provider, facade, a publishable configuration file and more.
Static Facade Interface
This package also integrates access to Intervention Image's central entry point, the ImageManager::class, via a static facade. The call provides access to the centrally configured image manager via singleton pattern.
The following code example shows how to read an image from an upload request the image facade in a Laravel route and save it on disk with a random file name.
use Illuminate\Http\Request;use Illuminate\Support\Facades\Route;use Illuminate\Support\Facades\Storage;use Illuminate\Support\Str;use Intervention\Image\Laravel\Facades\Image; Route::get('/', function (Request $request) { $upload = $request->file('image'); $image = Image::decode($upload) ->resize(300, 200); Storage::put( Str::random() . '.' . $upload->getClientOriginalExtension(), $image->encodeUsingFileExtension($upload->getClientOriginalExtension(), quality: 70) );});
Recent Courses on Laravel Daily
[NEW] Practical Laravel Security: Packages, Secrets, Supply-Chain Attacks
7 lessons
43 min read
Roles and Permissions in Laravel 13
14 lessons
57 min
Laravel 13 Eloquent: Expert Level
41 lessons
1 h 34 min