dev-master
9999999-dev https://github.com/anmishael/yii2-imageYii2 extension for image manipulating using Kohana Image Library.
BSD-3-Clause
The Requires
- php >=5.4.0
- yiisoft/yii2 *
by Mikel Anniuk
extension yii2 image
Yii2 extension for image manipulating using Kohana Image Library.
Simple to use Yii2 Framework extension for image manipulating using powerful Kohana Image Library. Inspired by old yii extension http://www.yiiframework.com/extension/image/ and Kohana Image Library https://github.com/kohana/image, (*1)
{ "require": { "anmishael/yii2-image": "dev-master" } }
In config file, (*2)
/config/web.php
Add image component, (*3)
'components' => array( ... 'image' => array( 'class' => 'yii\image\ImageDriver', 'driver' => 'GD', //GD or Imagick ), )
$file=Yii::getAlias('@app/pass/to/file'); $image=Yii::$app->image->load($file); header("Content-Type: image/png"); echo $image->resize($width,$height)->rotate(30)->render();
Supported methods out of the box from Kohana Image Library:, (*4)
$image->resize($width = NULL, $height = NULL, $master = NULL); $image->crop($width, $height, $offset_x = NULL, $offset_y = NULL); $image->sharpen($amount); $image->rotate($degrees); $image->save($file = NULL, $quality = 100); $image->render($type = NULL, $quality = 100); $image->reflection($height = NULL, $opacity = 100, $fade_in = FALSE); $image->flip($direction); $image->background($color, $opacity = 100); $image->watermark(Image $watermark, $offset_x = NULL, $offset_y = NULL, $opacity = 100);
Using resize with resize constrains, (*5)
$image->resize($width, $height, \yii\image\drivers\Image::HEIGHT); $image->resize($width, $height, \yii\image\drivers\Image::ADAPT)->background('#fff');
Possible resize constrains:, (*6)
// Resizing constraints ($master) const NONE = 0x01; const WIDTH = 0x02; const HEIGHT = 0x03; const AUTO = 0x04; const INVERSE = 0x05; const PRECISE = 0x06; const ADAPT = 0x07; const CROP = 0x08;
Using flip with flipping directions, (*7)
// Flipping directions ($direction) $image->flip(\yii\image\drivers\Image::HORIZONTAL);
Possible flipping directions:, (*8)
const HORIZONTAL = 0x11; const VERTICAL = 0x12;
Yii2 extension for image manipulating using Kohana Image Library.
BSD-3-Clause
extension yii2 image