2017 © Pedro Peláez
 

yii2-extension yii2-image

Yii2 extension for image manipulating using Kohana Image Library.

image

yurkinx/yii2-image

Yii2 extension for image manipulating using Kohana Image Library.

  • Thursday, December 8, 2016
  • by yurkinx
  • Repository
  • 16 Watchers
  • 61 Stars
  • 80,053 Installations
  • PHP
  • 17 Dependents
  • 0 Suggesters
  • 34 Forks
  • 7 Open issues
  • 3 Versions
  • 7 % Grown

The README.md

yii2-image

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)

Installation

Install as a composer package, (*2)

Use this method to get continuous updates., (*3)

composer require yurkinx/yii2-image

or include the dependency in the composer.json file:, (*4)

{
    "require": {
        "yurkinx/yii2-image": "^1.2"

    }
}

Configuration

In config file, (*5)

/config/web.php

Add image component, (*6)

'components' => array(
        ...
        'image' => array(
                'class' => 'yii\image\ImageDriver',
                'driver' => 'GD',  //GD or Imagick
                ),
            )

Usage

$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:, (*7)

$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, (*8)

$image->resize($width, $height, \yii\image\drivers\Image::HEIGHT);
$image->resize($width, $height, \yii\image\drivers\Image::ADAPT)->background('#fff');

Using resize with resize constrains and best quality output image [for Imagick driver only], (*9)

Use 1 for best speed and lower quality, 100 for best quality and lower speed. Only values 1,100 currently supported, (*10)

$image->resize($width, NULL, \yii\image\drivers\Image::WIDTH, 100);

Possible resize constrains:, (*11)

// 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, (*12)

// Flipping directions ($direction)
$image->flip(\yii\image\drivers\Image::HORIZONTAL);

Possible flipping directions:, (*13)

     const HORIZONTAL = 0x11;
     const VERTICAL   = 0x12;

The Versions

08/12 2016

dev-master

9999999-dev https://github.com/yurkinx/yii2-image

Yii2 extension for image manipulating using Kohana Image Library.

  Sources   Download

BSD-3-Clause

The Requires

 

by Yuri Kileev

extension yii2 image

24/06 2015

v1.1

1.1.0.0 https://github.com/yurkinx/yii2-image

Yii2 extension for image manipulating using Kohana Image Library.

  Sources   Download

BSD-3-Clause

The Requires

 

by Yuri Kileev

extension yii2 image

05/04 2015

v1.0

1.0.0.0 https://github.com/yurkinx/yii2-image

Yii2 extension for image manipulating using Kohana Image Library.

  Sources   Download

BSD-3-Clause

The Requires

 

by Yuri Kileev

extension yii2 image