Skip to main content

Introduction

Laravel provides a fluent image manipulation API through the Image facade. You can express operations such as resizing, cropping, encoding, and storing images in a consistent way across the framework. Internally, it uses Intervention Image and supports both PHP’s GD and Imagick extensions.
Image processing can consume significant CPU and memory. For large-scale image processing, avoid doing the work during an HTTP request and consider processing images as queue jobs.
This feature is available in Laravel v13.20.0 and later. If you are using an older version, update the framework to the latest release with composer update.

Installation

Before using image manipulation features, install the Intervention Image package with Composer.
Also make sure the PHP GD extension or Imagick extension is installed, depending on the driver you want to use.

Configuration

The configuration file is placed at config/image.php. If it does not exist, publish it with an Artisan command.
You can specify the default driver in the config file or with the IMAGE_DRIVER environment variable. Supported drivers are gd and imagick.

Loading images

The Image facade provides methods for creating image instances from several sources. Image contents are loaded lazily, so the underlying bytes are not read until processing or output is requested.

Uploaded files

Use the image method to retrieve an uploaded image from the request. It returns null when the file is not present.
Use the fromUpload method when creating an image from an UploadedFile instance.
You can retrieve the original file from an image instance created from an uploaded file with the file method.

Storage files

Use the fromStorage method to create an image instance from a file stored on a filesystem disk. The first argument is the file path and the second argument is the disk name.
You can also create an image through the Storage facade’s image method.

Other sources

You can also create image instances from bytes, local paths, URLs, and Base64 strings.

Manipulating images

Image instances are immutable. Each method returns a new instance with a transformation added to the processing pipeline, making method chaining natural. Transformations are applied in the order they are added, and encoding happens only once at the end.

Resizing

Other transformations

Conditional transformations

Image instances support the Conditionable trait, so you can apply transformations conditionally with when and unless.

Encoding

By default, images are encoded in their original format. Use the following methods to convert formats.
Use the quality method to set output quality from 1 to 100.
The optimize method is a shortcut for format conversion and quality configuration. The default is WebP at quality 70.
You can also retrieve the result as bytes, Base64, or a data URI.

Storing images

Use the store method to store an image on a filesystem disk. Laravel automatically generates a unique filename and returns the stored path.
Use storeAs when you want to specify the filename.
Use storePublicly and storePubliclyAs when storing with public visibility.
If storing fails, these methods return false.

Retrieving image information

Use the mimeType, extension, dimensions, width, and height methods to retrieve image information. These methods reflect the processed image. For example, calling width() after cover(400, 400) returns 400.

Custom drivers

Laravel’s image manager extends Illuminate\Support\Manager, so you can register custom drivers with the extend method. A custom driver implements the Illuminate\Contracts\Image\Driver interface. Its process method receives the original image bytes and the pipeline, then returns the processed image bytes.
Register the driver in a service provider’s boot method.
Use the using method to select a driver for a specific image.

Custom transformations

Define custom transformations with classes that implement the Illuminate\Contracts\Image\Transformation interface.
Register the handler in a service provider’s boot method.
After registration, apply it with the transform method.
Last modified on July 19, 2026