Intervention Image

Intervention Image is an open source PHP image handling and manipulation library. It provides an easier and expressive way to create, edit, and compose images and supports currently the two most common image processing libraries GD Library and Imagick.

The class is written to make the PHP image manipulating easier and more expressive. No matter if you want to create image thumbnails, watermarks, or format large image files Intervention Image helps you to manage every task in an easy way with as few lines of code as possible.

System Requirements

Intervention Image requires the following components to work correctly.

  • PHP >= 5.4
  • Fileinfo Extension

And one of the following image libraries.

  • GD Library (>=2.0) … or …
  • Imagick PHP extension (>=6.5.7)

Composer Installation

composer require intervention/image

After you have installed Intervention Image, open your Laravel config file config/app.php and add the following lines.

In the $providers array add the service providers for this package.

Intervention\Image\ImageServiceProvider::class

Add the facade of this package to the $aliases array.

'Image' => Intervention\Image\Facades\Image::class

Publish configuration in Laravel

$ php artisan vendor:publish --provider="Intervention\Image\ImageServiceProviderLaravelRecent"

Example :

 // create Image from file
$img = Image::make('public/foo.jpg');

// write text
$img->text('https://onlinelearningportal.website');

// write text at position
$img->text('https://onlinelearningportal.website', 120, 100);

// use callback to define details
$img->text('foo', 0, 0, function($font) {
    $font->file('foo/bar.ttf');
    $font->size(24);
    $font->color('#fdf6e3');
    $font->align('center');
    $font->valign('top');
    $font->angle(45);
});

// draw transparent text
$img->text('foo', 0, 0, function($font) {
    $font->color(array(255, 255, 255, 0.5));
});