Muhammad Yasir Amin

Loading websiteโ€ฆ

More from Muhammad Yasir Amin

Build Along With Me

Practical walkthroughs on Laravel, React, APIs and deployment workflows.

Subscribe on YouTube

How to Add a Blur Effect to an Image in Laravel 13 with Intervention Image 4

๐Ÿ› ๏ธ Laravel Tutorials4 min read

How to Add a Blur Effect to an Image in Laravel 13 with Intervention Image 4

Muhammad Yasir Amin

Muhammad Yasir Amin

Senior Full Stack Engineerโ€ขNov 12, 2026
How to Add a Blur Effect to an Image in Laravel 13 with Intervention Image 4

To blur an image in Laravel 13, decode it with Intervention Image 4 and call $image->blur($level), where the level is a number from 0 to 100. A low level such as 3 to 10 gives a soft blur, a high level hides the content. This tutorial shows the method, how to save or return the blurred image, and why you should limit the level when you use the GD driver.

Targets: Laravel 13 (PHP 8.3 to 8.5), intervention/image 4 and the GD or Imagick extension.

Step 1: Install Intervention Image

Code
composer require intervention/image

Step 2: Blur an image

PHP
use Intervention\Image\Drivers\Gd\Driver;
use Intervention\Image\ImageManager;

$manager = ImageManager::usingDriver(Driver::class);

$image = $manager->decode(storage_path('app/public/photos/original.jpg'));

$image->blur(10);

$image->save(storage_path('app/public/photos/blurred.jpg'));

The signature is blur(int $level = 5). It applies a Gaussian blur. Calling it without an argument uses level 5.

Which blur level should I use?

  • 1 to 5: a very light softening, useful to smooth small noise.
  • 5 to 20: a clearly visible blur that still shows shapes. Good for backgrounds and previews.
  • Above 30: details disappear. Use it for hiding sensitive content such as a locked preview.

The values above are practical guidelines, not official limits. The documented range is 0 to 100, so test the result on your own images.

Why is blur slow with GD?

The Intervention documentation warns that with the GD driver the blur method is performance intensive for larger blur levels. A big image with a high level can use a lot of CPU time. Three ways to stay safe:

  • Reduce the image first with scaleDown(width: 800) before blurring, so there are fewer pixels to process.
  • Limit the level you accept from users.
  • Use the Imagick driver if it is installed, because it is faster for large images.
PHP
$image = $manager->decode($path)
    ->scaleDown(width: 800)
    ->blur(15);

Step 3: Create a controller with a safe level

JavaScript
<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Intervention\Image\Drivers\Gd\Driver;
use Intervention\Image\Format;
use Intervention\Image\ImageManager;

class BlurController extends Controller
{
    public function __invoke(Request $request): Response
    {
        $data = $request->validate([
            'image' => ['required', 'image', 'mimes:jpg,jpeg,png,webp', 'max:5120'],
            'level' => ['nullable', 'integer', 'min:1', 'max:30'],
        ]);

        $image = ImageManager::usingDriver(Driver::class)
            ->decode($request->file('image')->getRealPath())
            ->scaleDown(width: 1200)
            ->blur((int) ($data['level'] ?? 8));

        $encoded = $image->encodeUsingFormat(Format::JPEG, quality: 85);

        return response((string) $encoded, 200, ['Content-Type' => 'image/jpeg']);
    }
}
CSS
Route::post('/blur', BlurController::class)->middleware('throttle:20,1');

The validation caps the file at 5 MB and the level at 30. The throttle protects the server from many heavy requests in a short time.

How do I create a blurred placeholder?

A common use is a tiny blurred preview shown while the full image loads:

PHP
$placeholder = $manager->decode($path)
    ->scaleDown(width: 40)
    ->blur(5)
    ->encodeUsingFormat(Format::JPEG, quality: 40);

$dataUri = $placeholder->toDataUri();

The tiny image is only a few hundred bytes, so you can store the data URI in the database and print it in an img tag as the initial source.

How do I check that it works?

  1. Post an image to /blur with level=5 and again with level=25.
  2. Compare the two results. The second should be clearly softer.
  3. Send level=80 and confirm validation rejects it with a 422 response.

Common mistakes

  • Blurring the full-size photo with GD: scale it down first.
  • Accepting any level from users: validate the range.
  • Using the old read() method: Intervention Image 4 uses decode().
  • Expecting blur to be secure hiding: a light blur can be partly reversed. For private content, do not serve the original at all.
  • Overwriting the original file: save to a new path so you can redo the effect.

FAQ

Is blur() a method of the image object?

Yes. In Intervention Image 4 it is Image::blur(int $level = 5) and it returns the image so you can chain more methods.

Can I blur only part of an image?

Blur affects the whole image. To blur a part, crop the region, blur it and insert it back with insert().

Which driver should I use in production?

Imagick if you can install it. GD works but is slower for large images and strong blur levels.

References

Article Index & Topic Tags
LaravelIntervention-ImageImagesBlur

YouTube Channel

Build Along With Me

Practical walkthroughs on Laravel, React, APIs and deployment workflows.

Muhammad Yasir Amin
Available for Contracts
Author & Solutions Architect

Senior Full Stack Engineer

Independent Senior Full Stack Engineer working on Laravel, React and Next.js applications, APIs and delivery workflows.

Laravel & PHP ApplicationsReact & Next.js InterfacesREST APIs & IntegrationsDatabase Queries & DebuggingDocker Development WorkflowsClear Scope & Handover
Discuss Your Next Step

What Does Your Application Need Next?

Share your current system, the problem you want to solve and what a useful result looks like. We can identify the right starting point and agree on a practical scope.

Technical Audit

Find the Next Useful Fix

Application Development

Scoped, Reviewable Milestones

Ongoing Support

Agreed Capacity and Priorities

Share your goals, current stack and requirements before the call.