PHPackages                             evgkan/yii2-widget-crop-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. evgkan/yii2-widget-crop-image

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

evgkan/yii2-widget-crop-image
=============================

Crop image input widget

0113PHP

Since Feb 15Pushed 9y ago1 watchersCompare

[ Source](https://github.com/evgkan/yii2-widget-crop-image)[ Packagist](https://packagist.org/packages/evgkan/yii2-widget-crop-image)[ RSS](/packages/evgkan-yii2-widget-crop-image/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (0)

yii2-widget-crop-image
======================

[](#yii2-widget-crop-image)

This widget allows you to select a rectangular area on the source image on the server, cache the new image and use it.

\##Installation

The preferred way to install this extension is through [composer](http://getcomposer.org/download/).

Either run

```
php composer.phar require --prefer-dist evgkan/yii2-widget-crop-image "*"

```

or add

```
"evgkan/yii2-widget-crop-image": "*"

```

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

\##Use

\###In admin(profile) view:

```

```

After you submit the form the model attribute will contain an array with the data framing, like this:

```
[
  'imgSrc' => ,
  'x1' => ,
  'y1' => ,
  'x2' => ,
  'y2' =>
]

```

\###In model:

```
public function getCropPhoto(){
  return CropImage::getCropImage($this->photo);
}

```

This method searches the cached image, using data framing. If cached image is absent, a new one is created. ###In common view:

```
