Basic Usage


Example

Static Example

  1. require 'vendor/autoload.php';
  2. // configure with favored image driver (gd by default)
  3. Image::configure(array('driver' => 'imagick'));
  4. // and you are ready to go ...
  5. $image = Image::make('public/foo.jpg')->resize(300, 200);

You can read more detailed information about installation and .


Intervention Image makes it super easy to read images. The Library takes away any annoying work, the only thing you have to do is to give a file path to the method make().

Read image from file

The method is highly variable. It not only reads filepaths but also the following input formats.

  • Path of the image in filesystem.
  • URL of an image (allow_url_fopen must be enabled).
  • Binary image data.
  • Data-URL encoded image data.
  • Base64 encoded image data.
  • PHP resource of type gd. (when using GD driver)
  • Imagick instance (when using Imagick driver)
  • Intervention\Image\Image instance
  • SplFileInfo instance (To handle Laravel file uploads via Symfony\Component\HttpFoundation\File\UploadedFile)

If you want to create a new empty image instance you can call the canvas() method with given width and height. Optionally it’s possible to define a background-color, if not passed the default the canvas background is transparent.

Creating new images with background color

See more examples to create new image instances in the api documentation.


After you initiated a new image instance with or canvas(), you can use the whole palette of manipulation methods on the instance.

Method chaining

Take a look at some of the methods in the following list.

Adjusting Images

Drawing

See the api documentation for the whole list of commands.


To create actually image data from an image object, you can access methods like to create encoded image data or use save to write an image into the filesystem. It’s also possible to send a HTTP with current image data.

Save an image in filesystem

  1. Image::make('foo.jpg')->resize(300, 200)->save('bar.jpg');

Outputting Image data