Overview Laravel 13.20 introduces a major convenience for developers by adding first-party support for image processing. Historically, handling media uploads required juggling external dependencies, configuring raw drivers, and writing multi-step storage logic. While third-party options remain robust, this new native API brings image resizing, cropping, and format conversion directly into the core framework syntax, reducing boilerplate and unifying the developer experience. Prerequisites To make the most of this tutorial, you should understand: * Basic routing and controller architecture in the Laravel framework. * PHP file handling concepts. * How to manage packages via Composer. Key Libraries & Tools * **Laravel 13**: The PHP web framework hosting the new first-party image manipulation features. * **Intervention Image**: The underlying PHP library that Laravel uses as its core engine. * **Spatie Media Library**: An advanced media-to-model binding package for complex collection management. Code Walkthrough Let us compare the traditional, multi-step approach with the new native syntax. The Manual Route: Intervention Image Previously, managing a thumbnail with raw Intervention Image required manual driver setup, file name generation, and explicit step-by-step encoding: ```php // Using Intervention Image directly $manager = new ImageManager(new Driver()); $image = $manager->read($request->file('photo')); $thumbnail = $image->scale(width: 300); $encoded = $thumbnail->toWebp(); Storage::disk('public')->put('thumbnails/photo.webp', $encoded); ``` This works. However, it forces you to manage intermediate state variables and interface directly with driver specifics. The Native Solution: Laravel 13.20 The new API simplifies this process by integrating image manipulations straight into the request and file upload flow: ```php // The streamlined Laravel way $request->file('photo') ->storeProcessed('thumbnails', function ($image) { $image->width(300)->format('webp'); }); ``` This chained approach eliminates manual driver instantiation and works natively with Laravel's file storage layer. Syntax Notes The new helper methods chain directly onto the uploaded file instance. Behind the scenes, Laravel resolves the active image driver configuration (like GD or Imagick), processes the closure, and saves the file in one unified transaction. It acts as a clean, fluent wrapper. Practical Examples Use the native API for: * Creating instant `.webp` thumbnails during user profile uploads. * Standardizing incoming catalog photographs to uniform dimensions. * Stripping metadata to optimize storage efficiency on simple blogs. Tips & Gotchas Remember that this native tool does not replace Spatie Media Library. While Laravel handles the physical file conversion, it does not manage database relations, multiple collections, or polymorphic model links. Furthermore, you must still run `composer require intervention/image` in your project, as Laravel relies on it under the hood.
Spatie Media Library
Products
Mar 2023 • 1 videos
High activity month for Spatie Media Library. Laravel Daily among the most active voices, with 1 videos across 1 sources.
Mar 2023
Jul 2026 • 1 videos
High activity month for Spatie Media Library. Laravel Daily among the most active voices, with 1 videos across 1 sources.
Jul 2026
- 19 hours ago
- Mar 5, 2023