Imagine library
Imagine is an OOP library for image manipulation. It allows you to crop, resize, and perform other manipulations with different images with the help of GD, Imagic, and Gmagic PHP extensions. Yii2-Imagine is a lightweight static wrapper for the library.
Getting ready
Create a new application by using composer, as described in the official guide at http://www.yiiframework.com/doc-2.0/guide-start-installation.html.
Install the extension with the following command:
composer require yiisoft/yii2-imagine
How to do it…
In your projects, you can use the extension in two ways:
Using it as a factory
Using inner methods
Using it as a factory
You can use an instance of the original Imagine
library class:
$imagine = new Imagine\Gd\Imagine(); // or $imagine = new Imagine\Imagick\Imagine(); // or $imagine = new Imagine\Gmagick\Imagine();
However, this depends on the existing corresponding PHP extensions in your system. You can use the getImagine()
method:
$imagine = \yii\imagine\Image::getImagine...