PHPackages                             kashifanwar47/yii2-image - 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. kashifanwar47/yii2-image

ActiveYii2-extension[Image &amp; Media](/categories/media)

kashifanwar47/yii2-image
========================

Yii2 extension for image manipulating.

v2.0.1(6y ago)07BSD-3-ClausePHPPHP &gt;=7.2.0

Since Jun 24Pushed 6y agoCompare

[ Source](https://github.com/kashifanwar47/yii2-image)[ Packagist](https://packagist.org/packages/kashifanwar47/yii2-image)[ Docs](https://github.com/kashifanwar47/yii2-image)[ RSS](/packages/kashifanwar47-yii2-image/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (1)Versions (6)Used By (0)

yii2-image
==========

[](#yii2-image)

[![Analytics](https://camo.githubusercontent.com/928a0c669f0376c15762ba542c53177ade16cf508840cb76ca50806b7062ab16/68747470733a2f2f67612d626561636f6e2e61707073706f742e636f6d2f55412d36353239353237352d312f796969322d696d616765)](https://github.com/igrigorik/ga-beacon)

Yii2 Framework Extension for Image Manipulation.
Forked from [yurkinx/yii2-image](https://github.com/yurkinx/yii2-image)

Installation
------------

[](#installation)

Add to your composer.json:

```
"require":
{
    "kashifanwar47/yii2-image": "~2.0"
}
```

after that exec `php composer.phar update or composer update`

Usage
-----

[](#usage)

### Simple

[](#simple)

```
$driver = \kashifanwar47\image\drivers\GD::classname(); // or `\kashifanwar47\image\drivers\Imagick::classname()`
/* @var $image \kashifanwar47\image\Image */
$image = \kashifanwar47\image\Image::load('@path/to/file', $driver);
$image->resize($width, $height, 'crop');
$image->save();
// or $image->save('@path/to/file2.png', $quality);
```

### Using component

[](#using-component)

configure in `main.php`:

```
'components' => [
    'image' => [
        'class' => 'kashifanwar47\\image\\Component',
        'driver' => 'kashifanwar47\\image\\drivers\\Imagick',
    ],
],
```

usage

```
/* @var $image \kashifanwar47\image\Image */
$image = Yii::$app->image->load('@path/to/file');
$image->flip('vertical')->save('@path/to/file2.jpeg', $quality);
```

Api
---

[](#api)

```
/**
 * Resize the image to the given size.
 * @param integer $width New width
 * @param integer $height New height
 * @param string $master [optional] Master dimension. Default is 'auto'
 * @return Image
 */
public function resize($width, $height, $master = Image::AUTO);

/**
 * Rotate the image.
 * @param integer $degrees
 * @return Image
 */
public function rotate($degrees);

/**
 * Flip the image along the horizontal or vertical axis.
 * @param string $direction May be Image::HORIZONTAL, Image::VERTICAL
 * @return Image
 */
public function flip($direction);

/**
 * Crop the image.
 * @param integer $width
 * @param integer  $height
 * @param integer|null $offset_x
 * @param integer|null $offset_y
 * @return Image
 */
public function crop($width, $height, $offset_x = null, $offset_y = null);

/**
 * Sharpen the image.
 * @param integer $amount
 * @return Image
 */
public function sharpen($amount);

/**
 * Add a reflection to the image.
 * @param integer $height reflection height
 * @param integer $opacity reflection opacity: 0-100
 * @param boolean $fade_in true to fade in, false to fade out
 * @return Image
 */
public function reflection($height = null, $opacity = 100, $fade_in = false);

/**
 * Add a watermark to the image with a specified opacity.
 * @param Image $watermark
 * @param integer $offset_x Offset from the left
 * @param integer $offset_y Offset from the top
 * @param integer $opacity Opacity of watermark: 1-100
 * @return Image
 */
public function watermark(Image $watermark, $offset_x = null, $offset_y = null, $opacity = 100);

/**
 * Fill the background color of the image.
 * @param string $color Hexadecimal color
 * @param integer $opacity Background opacity: 0-100
 * @return Image
 */
public function background($color, $opacity = 100);

/**
 * Save the image. If the filename is omitted, the original image will
 * be overwritten.
 * @param string|null $filename Image file name
 * @param integer|null $quality Quality 1-100 for JPEG, 0-9 for PNG
 * @return boolean
 * @throws \ErrorException
 */
public function save($filename = null, $quality = null);

/**
 * Render the image.
 * @param string|null $type
 * @param integer|null $quality
 * @return string binary string
 */
public function render($type = null, $quality = null);
```

### Image constants

[](#image-constants)

```
    // resize contants
    const WIDTH   = 'width';
    const HEIGHT  = 'height';
    const AUTO    = 'auto';
    const INVERSE = 'inverse';
    const PRECISE = 'precise';
    const ADAPT   = 'adapt';
    const CROP    = 'crop';

    // Flipping constants
    const HORIZONTAL = 'horizontal';
    const VERTICAL   = 'vertical';
```

License
-------

[](#license)

[BSD-3-Clause](http://opensource.org/licenses/BSD-3-Clause)

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 97.5% 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 ~382 days

Total

5

Last Release

2446d ago

Major Versions

v1.0.2 → v2.02019-08-31

PHP version history (2 changes)v1.0PHP &gt;=5.4.0

v2.0PHP &gt;=7.2.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/fb67b02dcaebb079098c54df6879851f721838593a6408fee5563e53b45406fe?d=identicon)[kashif\_pucit06](/maintainers/kashif_pucit06)

---

Top Contributors

[![mervick](https://avatars.githubusercontent.com/u/2429298?v=4)](https://github.com/mervick "mervick (77 commits)")[![kashifanwar47](https://avatars.githubusercontent.com/u/13700167?v=4)](https://github.com/kashifanwar47 "kashifanwar47 (2 commits)")

---

Tags

imageyii2extensionyii

### Embed Badge

![Health badge](/badges/kashifanwar47-yii2-image/health.svg)

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

###  Alternatives

[yurkinx/yii2-image

Yii2 extension for image manipulating using Kohana Image Library.

66412.9k9](/packages/yurkinx-yii2-image)[raoul2000/yii2-jcrop-widget

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

10248.3k2](/packages/raoul2000-yii2-jcrop-widget)[noam148/yii2-image-resize

A Yii2 component for resizing images (on the fly)

1144.6k7](/packages/noam148-yii2-image-resize)[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)
