定制 germanoricardi/yii2-imagecrop 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

germanoricardi/yii2-imagecrop

Composer 安装命令:

composer require germanoricardi/yii2-imagecrop

包简介

PHP class to crop images with yii2

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License

yii2-imagecrop

Crop images with this class is very simple!

Resources

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

Installation

The preferred way to install this extension is through composer.

Install

Either run

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

or add

"germanoricardi/yii2-imagecrop": "*"

to the require section of your composer.json file.

**Part of this class code was implemented by a document made available by fengyuanchen.

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.

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:

    $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

统计信息

  • 总下载量: 44
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-04-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固