2017 © Pedro Peláez
 

library yii2-imagick

Yii 2 class for working with Imagick

image

tpmanc/yii2-imagick

Yii 2 class for working with Imagick

  • Wednesday, September 14, 2016
  • by tpmanc
  • Repository
  • 1 Watchers
  • 15 Stars
  • 8,083 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 8 Forks
  • 1 Open issues
  • 5 Versions
  • 15 % Grown

The README.md

Yii 2 Imagick

Yii 2 class for working with Imagick., (*1)

Install via Composer

Run the following command, (*2)

$ composer require tpmanc/yii2-imagick "*"

or add, (*3)

$ "tpmanc/yii2-imagick": "*"

to the require section of your composer.json file., (*4)

Original image:, (*5)

"Original", (*6)

Get size

$img = Imagick::open('./image.jpg');
$img->getWidth();
$img->getHeight();

Resize image

Imagick::open('./image.jpg')->resize(400, 300)->saveTo('./resized.jpg');
Imagick::open('./image.jpg')->resize(400, false)->saveTo('./resized.jpg');

"Resize", (*7)

Create thumbnail

Imagick::open('./image.jpg')->thumb(200, 200)->saveTo('./thumb.jpg');

"Thumb", (*8)

Add border

$width = 5;
$color = '#000'
Imagick::open('./image.jpg')->border($width, $color)->saveTo('./result.jpg');

"Resize", (*9)

$width = 10;
$color = '#A91AD4'
Imagick::open('./image.jpg')->border($width, $color)->saveTo('./result.jpg');

"Resize", (*10)

Vertical and horizontal mirror image

// vertical
Imagick::open('./image.jpg')->flip()->saveTo('./result.jpg');
// horizontal
Imagick::open('./image.jpg')->flop()->saveTo('./result.jpg');

"Flip", (*11)

"Flop", (*12)

Crop

$xStart = 0;
$yStart = 0;
$xEnd = 150;
$yEnd = 150;
Imagick::open('./image.jpg')->crop($xStart, $yStart, $xEnd, $yEnd)->saveTo('./result.jpg');

"Crop", (*13)

Blur

$radius = 8;
$delta = 5;
Imagick::open('./image.jpg')->blur($radius, $delta)->saveTo('./result.jpg');

"Blur", (*14)

Watermark

Set watermark position

Use $xPosition and $yPosition to set watermark position., (*15)

$xPosition should be 'left', 'right' or 'center'; $yPosition should be 'top', 'bottom' or 'center'., (*16)

$xPosition = 'left';
$yPosition = 'top';
Imagick::open('./image.jpg')->watermark('./watermark.png'), $xPosition, $yPosition)->saveTo('./result.jpg');

"Watermark", (*17)

$xPosition = 'right';
$yPosition = 'center';
Imagick::open('./image.jpg')->watermark('./watermark.png'), $xPosition, $yPosition)->saveTo('./result.jpg');

"Watermark", (*18)

Set watermark size

Use $xSize and $ySize to set watermark size. Valid values:, (*19)

  • Number: $xSize = 100;, $ySize = 50, (*20)

  • Percent of parent: $xSize = '100%';, $ySize = '50%', (*21)

  • 'auto' to save proportion: $xSize = '100%';, $ySize = 'auto', (*22)

  • false: $xSize = 100;, $ySize = false, (*23)

$xPosition = 'center';
$yPosition = 'center';
$xSize = '100%';
$ySize = 'auto';
Imagick::open('./image.jpg')->watermark('./watermark.png'), $xPosition, $yPosition, $xSize, $ySize)->saveTo('./result.jpg');

"Watermark", (*24)

$xPosition = 'center';
$yPosition = 'center';
$xSize = '100%';
$ySize = '100%';
Imagick::open('./image.jpg')->watermark('./watermark.png'), $xPosition, $yPosition, $xSize, $ySize)->saveTo('./result.jpg');

"Watermark", (*25)

Set watermark offset

Use $xOffset and $yOffset to set offset from parent image border., (*26)

$xPosition = 'right';
$yPosition = 'bottom';
$xSize = false;
$ySize = false;
$xOffset = 50;
$yOffset = 50;
Imagick::open('./image.jpg')->watermark('./watermark.png'), $xPosition, $yPosition, $xSize, $ySize, $xOffset, $yOffset)->saveTo('./result.jpg');

"Watermark", (*27)

The Versions

14/09 2016

dev-master

9999999-dev https://github.com/tpmanc/yii2-imagick

Yii 2 class for working with Imagick

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

The Development Requires

yii2 yii imagick

05/02 2016

v1.3

1.3.0.0 https://github.com/tpmanc/yii2-imagick

Yii 2 class for working with Imagick

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

yii2 yii imagick

02/08 2015

v1.2

1.2.0.0 https://github.com/tpmanc/yii2-imagick

Yii 2 class for working with Imagick

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

yii2 yii imagick

31/07 2015

v1.1

1.1.0.0 https://github.com/tpmanc/yii2-imagick

Yii 2 class for working with Imagick

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

yii2 yii imagick

31/07 2015

v1.0

1.0.0.0 https://github.com/tpmanc/yii2-imagick

Yii 2 class for working with Imagick

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.4.0

 

yii imagick