PHPackages                             tpmanc/yii2-imagick - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Image &amp; Media](/categories/media)
4. /
5. tpmanc/yii2-imagick

ActiveLibrary[Image &amp; Media](/categories/media)

tpmanc/yii2-imagick
===================

Yii 2 class for working with Imagick

1.3.2(6y ago)18168.8k—9.6%7[2 issues](https://github.com/tpmanc/yii2-imagick/issues)2BSD-3-ClausePHPPHP &gt;=5.4.0

Since Jul 31Pushed 6y ago1 watchersCompare

[ Source](https://github.com/tpmanc/yii2-imagick)[ Packagist](https://packagist.org/packages/tpmanc/yii2-imagick)[ Docs](https://github.com/tpmanc/yii2-imagick)[ RSS](/packages/tpmanc-yii2-imagick/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (7)Used By (2)

Yii 2 Imagick
=============

[](#yii-2-imagick)

Yii 2 class for working with Imagick.

Install via Composer
--------------------

[](#install-via-composer)

Run the following command

```
$ composer require tpmanc/yii2-imagick "*"
```

or add

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

to the require section of your `composer.json` file.

Original image:

[!["Original"](https://camo.githubusercontent.com/730b3c344ae918e8cb5f133aff95e40ec973e861f770e19478fe0df51afadc52/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f6f726967696e616c2e6a7067)](https://camo.githubusercontent.com/730b3c344ae918e8cb5f133aff95e40ec973e861f770e19478fe0df51afadc52/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f6f726967696e616c2e6a7067)

Get size
--------

[](#get-size)

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

Resize image
------------

[](#resize-image)

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

[!["Resize"](https://camo.githubusercontent.com/b760275957b32ef82d93202e4df24905b968481c6aff8d22ba21644539fac688/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f726573697a652e6a7067)](https://camo.githubusercontent.com/b760275957b32ef82d93202e4df24905b968481c6aff8d22ba21644539fac688/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f726573697a652e6a7067)

Create thumbnail
----------------

[](#create-thumbnail)

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

[!["Thumb"](https://camo.githubusercontent.com/4cd5eecdc986e5bc166c6e7f3ee7fe8f7e545dd7e4ac64860295bb367aedccdc/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f7468756d622e6a7067)](https://camo.githubusercontent.com/4cd5eecdc986e5bc166c6e7f3ee7fe8f7e545dd7e4ac64860295bb367aedccdc/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f7468756d622e6a7067)

Add border
----------

[](#add-border)

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

[!["Resize"](https://camo.githubusercontent.com/4da356bb8608fc5e80376557b005293b92d247678703cc03f2dd4dece60e5dd4/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f626f726465722d312e6a7067)](https://camo.githubusercontent.com/4da356bb8608fc5e80376557b005293b92d247678703cc03f2dd4dece60e5dd4/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f626f726465722d312e6a7067)

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

[!["Resize"](https://camo.githubusercontent.com/2d52cf8adc5d80f08ee75f1cb8eb4a490e0beaeca10be30833dca7bc14106907/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f626f726465722d322e6a7067)](https://camo.githubusercontent.com/2d52cf8adc5d80f08ee75f1cb8eb4a490e0beaeca10be30833dca7bc14106907/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f626f726465722d322e6a7067)

Vertical and horizontal mirror image
------------------------------------

[](#vertical-and-horizontal-mirror-image)

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

[!["Flip"](https://camo.githubusercontent.com/28f27dea9977e356ec0b822839600d5b50a8ca1170b6c1a753230fa182236ce2/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f666c69702e6a7067)](https://camo.githubusercontent.com/28f27dea9977e356ec0b822839600d5b50a8ca1170b6c1a753230fa182236ce2/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f666c69702e6a7067)

[!["Flop"](https://camo.githubusercontent.com/04fe08e95504637c7e3d831aa55379e334e617a92347c6755bfa19d76320a7c3/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f666c6f702e6a7067)](https://camo.githubusercontent.com/04fe08e95504637c7e3d831aa55379e334e617a92347c6755bfa19d76320a7c3/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f666c6f702e6a7067)

Crop
----

[](#crop)

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

[!["Crop"](https://camo.githubusercontent.com/457ca5b1a382b93db4e77d02f406afb70fa95b5e00cc50681fd47698f2600e95/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f63726f702e6a7067)](https://camo.githubusercontent.com/457ca5b1a382b93db4e77d02f406afb70fa95b5e00cc50681fd47698f2600e95/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f63726f702e6a7067)

Blur
----

[](#blur)

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

[!["Blur"](https://camo.githubusercontent.com/746f9ebc775f17c25596b4a263484f5dbe7398fc14ce994d1c6bee698977ac6c/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f626c75722e6a7067)](https://camo.githubusercontent.com/746f9ebc775f17c25596b4a263484f5dbe7398fc14ce994d1c6bee698977ac6c/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f626c75722e6a7067)

Watermark
---------

[](#watermark)

### Set watermark position

[](#set-watermark-position)

Use `$xPosition` and `$yPosition` to set watermark position.

`$xPosition` should be 'left', 'right' or 'center'; `$yPosition` should be 'top', 'bottom' or 'center'.

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

[!["Watermark"](https://camo.githubusercontent.com/213931ae1fad6bf775f4730cc16936db9b2f00ca2ff0fefc021ce67fce7fdfcc/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f77617465726d61726b2d312e6a7067)](https://camo.githubusercontent.com/213931ae1fad6bf775f4730cc16936db9b2f00ca2ff0fefc021ce67fce7fdfcc/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f77617465726d61726b2d312e6a7067)

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

[!["Watermark"](https://camo.githubusercontent.com/6740d85e4dcb35073548f53431a417934c87d8f7f8f8e21fd254f7f8b77b86b1/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f77617465726d61726b2d322e6a7067)](https://camo.githubusercontent.com/6740d85e4dcb35073548f53431a417934c87d8f7f8f8e21fd254f7f8b77b86b1/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f77617465726d61726b2d322e6a7067)

### Set watermark size

[](#set-watermark-size)

Use `$xSize` and `$ySize` to set watermark size. Valid values:

- Number: `$xSize = 100;`, `$ySize = 50`
- Percent of parent: `$xSize = '100%';`, `$ySize = '50%'`
- `'auto'` to save proportion: `$xSize = '100%';`, `$ySize = 'auto'`
- `false`: `$xSize = 100;`, `$ySize = false`

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

[!["Watermark"](https://camo.githubusercontent.com/5840e9c5919ae95db5a0cd0695e482c2816c254286de112392ff2fa3c6d999ce/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f77617465726d61726b2d332e6a7067)](https://camo.githubusercontent.com/5840e9c5919ae95db5a0cd0695e482c2816c254286de112392ff2fa3c6d999ce/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f77617465726d61726b2d332e6a7067)

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

[!["Watermark"](https://camo.githubusercontent.com/28d29a212a813079466c66515026bea9dbf08286e952593c0a703b5f8d57324a/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f77617465726d61726b2d342e6a7067)](https://camo.githubusercontent.com/28d29a212a813079466c66515026bea9dbf08286e952593c0a703b5f8d57324a/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f77617465726d61726b2d342e6a7067)

### Set watermark offset

[](#set-watermark-offset)

Use `$xOffset` and `$yOffset` to set offset from parent image border.

```
$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"](https://camo.githubusercontent.com/0b23ba31ecdb6a7709db314462d49dcd072f5db31ea3f03c0efd85520aa53426/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f77617465726d61726b2d352e6a7067)](https://camo.githubusercontent.com/0b23ba31ecdb6a7709db314462d49dcd072f5db31ea3f03c0efd85520aa53426/68747470733a2f2f7261772e6769746875622e636f6d2f74706d616e632f796969322d696d616769636b2f6d61737465722f6578616d706c65732f77617465726d61726b2d352e6a7067)

###  Health Score

38

—

LowBetter than 85% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community16

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 96% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~318 days

Recently: every ~398 days

Total

6

Last Release

2352d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/995c4519028795d89f3c599b17f7379977f82163da07b39cdfced90fdf665fd0?d=identicon)[tpmanc](/maintainers/tpmanc)

---

Top Contributors

[![tpmanc](https://avatars.githubusercontent.com/u/6450943?v=4)](https://github.com/tpmanc "tpmanc (24 commits)")[![DumpOfTheVar](https://avatars.githubusercontent.com/u/4920070?v=4)](https://github.com/DumpOfTheVar "DumpOfTheVar (1 commits)")

---

Tags

imagickphpyii2imagickyii2yii

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/tpmanc-yii2-imagick/health.svg)

```
[![Health](https://phpackages.com/badges/tpmanc-yii2-imagick/health.svg)](https://phpackages.com/packages/tpmanc-yii2-imagick)
```

###  Alternatives

[raoul2000/yii2-jcrop-widget

This extension is a wrapper for the jQuery Image Cropping Plugin (jcrop)

10248.3k2](/packages/raoul2000-yii2-jcrop-widget)[orbitale/imagemagick-php

A system that allows creating commands to send to the exec() function to use ImageMagick's powerful features.

43385.7k1](/packages/orbitale-imagemagick-php)[trntv/yii2-glide

Yii2 Glide Extension

41269.5k9](/packages/trntv-yii2-glide)[maxmirazh33/yii2-uploadable-cropable-image

Yii2 extension for upload and crop images

1020.8k](/packages/maxmirazh33-yii2-uploadable-cropable-image)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
