2017 © Pedro Peláez
 

yii2-extension yii2-imagecrop

PHP class to crop images with yii2

image

germanoricardi/yii2-imagecrop

PHP class to crop images with yii2

  • Tuesday, May 17, 2016
  • by germanoricardi
  • Repository
  • 1 Watchers
  • 0 Stars
  • 27 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 3 Versions
  • 17 % Grown

The README.md

Latest Stable Version Total Downloads Latest Unstable Version License, (*1)

yii2-imagecrop

Crop images with this class is very simple!, (*2)

Resources

  • Centralized autocrop;
  • Customized cutting area with json;
  • Watermark;

Installation

The preferred way to install this extension is through composer., (*3)

Install

Either run, (*4)

$ php composer.phar require germanoricardi/yii2-imagecrop "*"

or add, (*5)

"germanoricardi/yii2-imagecrop": "*"

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

_**Part of this class code was implemented by a document made available by fengyuanchen_., (*7)

How to use

Add the following code in a controller, the image that will be used for cutting should already be on your server, that is, the code should be run after the file upload. The original image is always preserved., (*8)

use germanoricardi\imagecrop\ImageCrop;

public function actionCrop(){
    $imageCrop = new ImageCrop();
    $imageCrop->imageSourcePath = '@webroot/medias/';
    $imageCrop->imagesSizes     = [
        ['path' => '@webroot/medias/thumbs/', 'width' => '200', 'height' => '200'],
        ['path' => '@webroot/medias/large/', 'width' => '800', 'height' => '600', 'watermark' => '@webroot/watermark.png']
    ];
    $imageCrop->imageFileName   = 'image-to-crop.jpg';
    $imageCrop->init();
}

AJAX

If you are working with a jQuery plugin for crop image parameters can be passed to the class via AJAX as follows:, (*9)

    $imageCrop = new ImageCrop();
    $imageCrop->imageSourcePath = '@webroot/medias/';
    $imageCrop->imagesSizes     = [
        ['path' => '@webroot/medias/thumbs/', 'width' => '200', 'height' => '200'],
        ['path' => '@webroot/medias/large/', 'width' => '800', 'height' => '600', 'watermark' => '@webroot/watermark.png']
    ];
    $imageCrop->imageFileName   = 'image-to-crop.jpg';

    // AJAX
    $imageCrop->data            = '{"x":220,"y":26,"width":1168,"height":1168,"rotate":0,"scaleX":1,"scaleY":1}';

    $imageCrop->init();

License

License, (*10)

The Versions

17/05 2016

dev-master

9999999-dev https://github.com/germanoricardi/yii2-imagecrop

PHP class to crop images with yii2

  Sources   Download

MIT

The Requires

 

by Germano Ricardi

crop yii2 crop yii2 image crop crop class

17/05 2016

1.0.1

1.0.1.0 https://github.com/germanoricardi/yii2-imagecrop

PHP class to crop images with yii2

  Sources   Download

MIT

The Requires

 

by Germano Ricardi

crop yii2 crop yii2 image crop crop class

22/04 2016

1.0.0

1.0.0.0 https://github.com/germanoricardi/yii2-imagecrop

PHP class to crop images with yii2

  Sources   Download

MIT

The Requires

 

by Germano Ricardi

crop yii2 crop yii2 image crop crop class