Updated 29 June 2026
Intervention Image Laravel is a powerful package for image manipulation in Laravel applications.
It lets you resize, crop, rotate, compress, optimize, and convert images using the PHP GD Extension.
Whether you’re building an eCommerce store or CMS, Intervention Image Laravel helps improve image quality and application performance.
It also reduces image sizes, speeds up page loading, and delivers a better user experience.
In this guide, you’ll learn how to install the GD Extension and configure Intervention Image Laravel step by step.
You’ll also discover how to process uploaded images, generate thumbnails, and optimize images with practical examples.
By the end of this tutorial, you’ll be able to use Intervention Image Laravel efficiently in your Laravel projects.
Intervention Image is a popular open-source PHP image handling and manipulation library.
It provides a simple and expressive API for working with images in Laravel and PHP applications.
With Intervention Image, you can:
The package supports two image processing drivers:
The GD driver is the most commonly used because it comes bundled with PHP and is easy to install.
GD is a graphics library used to create and manipulate image files.
It enables PHP applications to perform operations such as resizing, cropping, drawing text, and dynamically generating images.
Intervention Image relies on either GD or Imagick to process images. If neither extension is installed, image manipulation features will not work.
Before installing Intervention Image, verify whether GD is already enabled.
Run:
|
1 2 |
php -m | grep gd |
Alternatively:
|
1 2 |
php -i | grep GD |
If GD is installed, you’ll see output similar to:
|
1 2 |
gd GD Support => enabled |
Install GD using:
|
1 2 3 |
sudo apt update sudo apt install php-gd |
For a specific PHP version:
|
1 2 |
sudo apt install php8.2-gd |
Restart your web server:
|
1 2 |
sudo systemctl restart apache2 |
Or for Nginx:
|
1 2 3 |
sudo systemctl restart php8.2-fpm sudo systemctl restart nginx |
Install the extension:
|
1 2 |
sudo yum install php-gd |
Restart Apache:
|
1 2 |
sudo systemctl restart httpd |
php.ini file.|
1 2 |
;extension=gd |
|
1 2 |
extension=gd |
Run:
|
1 2 |
php -m |
You should see:
|
1 2 |
gd |
You can also create a PHP info file:
|
1 |
<?php phpinfo(); |
Open it in your browser and search for GD Support.
Install the package using Composer:
|
1 2 |
composer require intervention/image |
Verify installation:
|
1 2 |
composer show intervention/image |
Import the Image Manager:
|
1 2 3 |
use Intervention\Image\ImageManager; use Intervention\Image\Drivers\Gd\Driver; |
Create a manager instance:
|
1 2 |
$manager = new ImageManager(new Driver()); |
Read an image:
|
1 |
$image = $manager->read(storage_path('app/public/sample.jpg')); |
Resize the image:
|
1 |
$image->resize(300, 300); |
Save the image:
|
1 |
$image->save(storage_path('app/public/resized.jpg')); |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
use Illuminate\Http\Request; use Intervention\Image\ImageManager; use Intervention\Image\Drivers\Gd\Driver; public function upload(Request $request) { $request->validate([ 'image' => 'required|image' ]); $manager = new ImageManager(new Driver()); $image = $manager->read($request->file('image')); $image->resize(800, 600); $filename = time().'.jpg'; $image->save(public_path('uploads/'.$filename)); return back()->with('success', 'Image uploaded successfully.'); } |
|
1 2 3 4 5 6 7 8 9 10 11 |
<form action="{{ route('image.upload') }}" method="POST" enctype="multipart/form-data"> @csrf <input type="file" name="image"> <button type="submit"> Upload </button> </form> |
|
1 |
$image->crop(400, 400); |
This crops the image to a fixed size of 400×400.
|
1 |
$image->rotate(90); |
Rotate the image by 90 degrees.
Convert PNG to JPG:
|
1 |
$image->save('converted.jpg'); |
Intervention automatically determines the format based on the file extension.
Error:
|
1 2 |
GD Library extension not available |
Solution:
Install and enable the GD extension, then restart your web server.
|
1 2 |
Class "Intervention\Image\ImageManager" not found |
Solution:
|
1 2 3 |
composer install composer dump-autoload |
Large image uploads may exceed PHP memory limits.
Increase memory:
|
1 2 |
memory_limit = 512M |
Restart PHP afterward.
| Feature | GD | Imagick |
|---|---|---|
| Installation | Easy | Moderate |
| Performance | Good | Excellent |
| Memory Usage | Low | Higher |
| Advanced Features | Basic | Advanced |
| Laravel Compatibility | Excellent | Excellent |
For most Laravel projects, GD provides everything needed for image resizing and optimization.
Intervention Image is one of the best libraries for image manipulation in Laravel applications.
Before using it, ensure that the GD extension is properly installed and enabled on your server.
Once configured, you can easily resize, crop, rotate, and optimize images with minimal code.
By combining Laravel with Intervention Image and the GD extension,
developers can create powerful image-processing workflows while maintaining excellent application performance.
Also you can hire laravel developers to customize this feature for your business needs.
Kindly explore our extensions.
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.