This extension adds most common image functions and also acts as a wrapper to Imagine image manipulation library.
The preferred way to install this extension is through composer.
Either run
php composer.phar require --prefer-dist yiisoft/yii2-imagine "*"
or add
"yiisoft/yii2-imagine": "*"
to the require
section of your composer.json.
This extension is a wrapper to the Imagine and also adds the most commonly used image manipulation methods.
The following example shows how to use this extension:
use yii\imagine\Image;
// frame, rotate and save an image
Image::frame('path/to/image.jpg', 5, '666', 0)
->rotate(-8)
->save('path/to/destination/image.jpg', ['quality' => 50]);
Note that each Image
method returns an instance of \Imagine\Image\ImageInterface
.
This means you can make use of the methods included in the Imagine
library: