Laravel Image Processing with Illuminate\\Image | Mohamed Said       [Skip to content](#main)  [ ![](https://cdn.msaied.com/01KT78WE565VEMM3PSNQAAB0MH.png) Mohamed SaidLaravel Backend Engineer ](https://www.msaied.com/public) - [Home](https://www.msaied.com/public)
- [Projects](https://www.msaied.com/public/projects)
- [Articles](https://www.msaied.com/public/articles)
- [Certificates](https://www.msaied.com/public/certificates)
- [About](https://www.msaied.com/public#about)

           [  Contact](https://www.msaied.com/public#contact) Menu 

Menu
----

Close 

 - [HomeStart here](https://www.msaied.com/public)
- [ProjectsCase studies](https://www.msaied.com/public/projects)
- [ArticlesEngineering notes](https://www.msaied.com/public/articles)
- [CertificatesCredentials](https://www.msaied.com/public/certificates)
- [AboutHow I work](https://www.msaied.com/public#about)
- [ContactGet in touch](https://www.msaied.com/public#contact)

  [Start a conversation](https://www.msaied.com/public#contact) [WhatsApp](https://wa.me/201094619204) [Email](mailto:hello@msaied.com) 

 1. [Home](https://www.msaied.com/public)
2. /
3. [Articles](https://www.msaied.com/public/articles)
4. /
5. [Laravel](https://www.msaied.com/public/articles?category=laravel)
6. /
7. Laravel's First-Party Image Processing: A Practical Guide to Illuminate\\Image

   [Laravel](https://www.msaied.com/public/articles?category=laravel) 

 Laravel's First-Party Image Processing: A Practical Guide to Illuminate\\Image
===============================================================================

 Laravel 13.20 ships a fluent, immutable image processing API via Illuminate\\Image, backed by Intervention Image v4. Resize, crop, convert to WebP, and store results on any filesystem disk—no third-party package wiring required.

 ![](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp) [Mohamed Said](https://www.msaied.com/public#person) Published 23 Jul 2026 · Updated 23 Jul 2026 · 3 min read

ShareCopy linkCopied

 ![Laravel's First-Party Image Processing: A Practical Guide to Illuminate\Image](https://cdn.msaied.com/460/5cb923ccb4db6434fec59637652666f0.png) 

  On this page +1. [Laravel 13.20 Introduces First-Party Image Processing](#laravel-1320-introduces-first-party-image-processing)
2. [Setup](#setup)
3. [Creating an Image Instance](#creating-an-image-instance)
4. [How the Pipeline Works](#how-the-pipeline-works)
5. [Resizing Methods](#resizing-methods)
6. [Formats, Quality, and optimize()](#formats-quality-and-optimize)
7. [Storing Results](#storing-results)
8. [Practical Example: Avatar Upload Controller](#practical-example-avatar-upload-controller)
9. [Conditional Transformations](#conditional-transformations)
10. [Key Takeaways](#key-takeaways)

 Laravel 13.20 Introduces First-Party Image Processing
-----------------------------------------------------

Laravel 13.20 added native image processing through the new `Illuminate\Image` component ([PR #59276](https://github.com/laravel/framework/pull/59276)). Before this release, every resize or WebP conversion required wiring up a third-party package manually. Now the framework ships a fluent, immutable API that handles resizing, cropping, format conversion, quality control, effects, and storing results on any filesystem disk.

Setup
-----

The GD and Imagick drivers are backed by [Intervention Image](https://github.com/Intervention/image) v4, which is a *suggested* dependency. Install it with:

```bash
composer require intervention/image:^4.0

```

Laravel defaults to the GD driver. Switch to Imagick per-image or globally via the `images.default` config:

```php
$image->usingImagick()->toBytes();

```

Creating an Image Instance
--------------------------

The new `Request::image()` method is the most convenient entry point for uploads:

```php
$image = $request->image('avatar'); // ?Illuminate\Image\Image

```

For every other source, use the `Image` facade or `Storage`:

```php
$image = Image::fromPath('/path/to/photo.jpg');
$image = Image::fromUrl('https://example.com/photo.jpg');
$image = Image::fromStorage('uploads/photo.jpg', 's3');
$image = Storage::disk('s3')->image('uploads/photo.jpg');

```

How the Pipeline Works
----------------------

Every transformation returns a **new** `Image` instance and nothing is processed until you request output (`store()`, `toBytes()`, `width()`, etc.). This lets you branch a single base image into multiple variants without side effects:

```php
$photo = Image::fromStorage('uploads/photo.jpg')->orient();

$thumbnail = $photo->cover(300, 300)->quality(60)->toWebp();
$display   = $photo->scale(width: 1600)->quality(80)->toWebp();

$thumbnail->storeAs('photos', 'photo-thumb.webp', disk: 's3');
$display->storeAs('photos', 'photo-display.webp', disk: 's3');

```

Calling `orient()` first auto-rotates the image using EXIF data—essential for phone camera uploads.

Resizing Methods
----------------

| Method | Behaviour | |---|---| | `cover($w, $h)` | Resize and crop to exact dimensions | | `contain($w, $h, $bg)` | Fit inside dimensions, pad with background | | `scale($w, $h)` | Proportional resize, never upscales | | `resize($w, $h)` | Force exact dimensions, may distort | | `crop($w, $h, $x, $y)` | Cut a region at the given offset |

Formats, Quality, and optimize()
--------------------------------

Convert to any common format with dedicated methods:

```php
$image->toWebp()->quality(80);
$image->toAvif()->quality(70);
$image->toPng();

```

The `optimize()` shortcut converts to WebP at quality 70 by default:

```php
$image->optimize();           // WebP @ 70
$image->optimize('avif', 60); // AVIF @ 60

```

Storing Results
---------------

```php
$path = $image->store('avatars');                     // hashed filename
$path = $image->storeAs('avatars', 'user-1.webp');    // explicit name
$path = $image->storePublicly('avatars', disk: 's3'); // public visibility

```

The hashed filename automatically uses the correct extension for the output format.

Practical Example: Avatar Upload Controller
-------------------------------------------

```php
public function update(Request $request)
{
    $request->validate(['avatar' => ['required', 'image', 'max:5120']]);

    $path = $request->image('avatar')
        ->orient()
        ->cover(512, 512)
        ->optimize()
        ->storePublicly('avatars', disk: 's3');

    $request->user()->update(['avatar_path' => $path]);

    return back();
}

```

Conditional Transformations
---------------------------

`Image` uses Laravel's `Conditionable` trait, so `when()` works as expected:

```php
$image = $request->image('photo')
    ->when($request->boolean('grayscale'), fn ($img) => $img->grayscale())
    ->scale(width: 1200)
    ->optimize();

```

Key Takeaways
-------------

- **No extra wiring**: `Illuminate\Image` is built into Laravel 13.20; just install Intervention Image v4.
- **Immutable pipeline**: transformations return new instances, making multi-variant generation safe and clean.
- **`scale()` never upscales**: safe default for responsive image generation.
- **`optimize()`** is a one-call shortcut to WebP at quality 70.
- **Images cannot be serialized** to queued jobs—store first, pass the path.
- **`ImageException`** is the single exception type for all processing failures.

---

*Source: [A Practical Guide to Laravel's First-Party Image Processing](https://laravel-news.com/a-practical-guide-to-laravels-first-party-image-processing) — Laravel News*

- [Laravel](https://www.msaied.com/public/articles?search=Laravel)
- [Image Processing](https://www.msaied.com/public/articles?search=Image%20Processing)
- [Illuminate\\Image](https://www.msaied.com/public/articles?search=Illuminate%5CImage)
- [WebP](https://www.msaied.com/public/articles?search=WebP)
- [Intervention Image](https://www.msaied.com/public/articles?search=Intervention%20Image)

 Frequently asked questions 
---------------------------

  Do I need to install a separate package to use Laravel's image processing in 13.20?Yes, one package is required. The `Illuminate\\Image` component is built into Laravel 13.20, but it relies on Intervention Image v4 as a suggested dependency. Run `composer require intervention/image:^4.0` to enable the GD or Imagick driver.

   Can I send an Image instance to a Laravel queued job?No. Attempting to serialize an `Image` instance for a queued job throws an `ImageException`. The recommended pattern is to store the image first and pass the resulting file path to the job instead.

   What is the difference between scale() and resize() in Illuminate\\Image?`scale()` resizes proportionally and never upscales the image—it maps to Intervention's `scaleDown()` internally. `resize()` forces exact dimensions and may distort the image if the aspect ratio differs.

   ![Mohamed Said](https://cdn.msaied.com/01M22N44A70A5MC2S599JP0MPH.webp)About the author
----------------

[Mohamed Said](https://www.msaied.com/public#person)Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

[About](https://www.msaied.com/public#about) [GitHub ↗](https://github.com/EG-Mohamed) [LinkedIn ↗](https://www.linkedin.com/in/msaiedm/) [WhatsApp ↗](https://wa.me/201094619204) [Email Address ↗](mailto:hello@msaied.com) [My CV ↗](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)  

   [Previous article6 Laravel UI Kits and Component Libraries for 2025 (Tailwind v4 + Livewire)](https://www.msaied.com/public/articles/6-laravel-ui-kits-and-component-libraries-for-2025-tailwind-v4-livewire) [Next articleLaravel Founders Summit 2026: A One-Day Gathering for Laravel Business Leaders](https://www.msaied.com/public/articles/laravel-founders-summit-2026-a-one-day-gathering-for-laravel-business-leaders)  

   On this page
-------------

1. [Laravel 13.20 Introduces First-Party Image Processing](#laravel-1320-introduces-first-party-image-processing)
2. [Setup](#setup)
3. [Creating an Image Instance](#creating-an-image-instance)
4. [How the Pipeline Works](#how-the-pipeline-works)
5. [Resizing Methods](#resizing-methods)
6. [Formats, Quality, and optimize()](#formats-quality-and-optimize)
7. [Storing Results](#storing-results)
8. [Practical Example: Avatar Upload Controller](#practical-example-avatar-upload-controller)
9. [Conditional Transformations](#conditional-transformations)
10. [Key Takeaways](#key-takeaways)

 ###  Have a technical challenge?

 Tell me what you’re building. I reply within two working days.

[Start a conversation](https://www.msaied.com/public#contact) 

   Related articles
-----------------

 [ ![](https://cdn.msaied.com/740/cce86edc21eddcbdd2f2454fadaf9c70.png)  · 3 min read### The Pipeline Pattern in Laravel: Custom Pipelines Beyond Middleware

5 Oct 2026 ](https://www.msaied.com/public/articles/the-pipeline-pattern-in-laravel-custom-pipelines-beyond-middleware-1) [ ![](https://cdn.msaied.com/739/2d6897fdcdcf090613f96f72a64b8a78.png)  · 4 min read### MySQL Full-Text Search in Laravel: Indexes, Relevance Scoring, and Boolean Mode

4 Oct 2026 ](https://www.msaied.com/public/articles/mysql-full-text-search-in-laravel-indexes-relevance-scoring-and-boolean-mode) [ ![](https://cdn.msaied.com/738/073696a3fefe18bec825beec5ac658f5.png)  · 4 min read### Laravel Queue Rate-Limited Middleware: Throttling Jobs Without Losing Work

4 Oct 2026 ](https://www.msaied.com/public/articles/laravel-queue-rate-limited-middleware-throttling-jobs-without-losing-work) 

  Have a technical challenge?
----------------------------

Tell me what you’re building. I reply within two working days.

 [Discuss your project ↗](https://www.msaied.com/public#contact) 

  © 2026 Mohamed Said · Built with Laravel, meant to last.Senior Backend Engineer specializing in Laravel, scalable SaaS platforms, APIs, and cloud infrastructure. I build secure, high-performance web applications that help businesses grow.

 - [Home](https://www.msaied.com/public)
- [Articles](https://www.msaied.com/public/articles)
- [Certificates](https://www.msaied.com/public/certificates)
- [GitHub](https://github.com/EG-Mohamed)
- [LinkedIn](https://www.linkedin.com/in/msaiedm/)
- [WhatsApp](https://wa.me/201094619204)
- [Email Address](mailto:hello@msaied.com)
- [My CV](https://drive.google.com/file/u/0/d/1MF20IPRJyzfy32mhEutjL5EpSls0w2Q8/view)
- [Sitemap](https://www.msaied.com/public/sitemap.xml)
