zoukankan      html  css  js  c++  java
  • yii2-imagine的使用

    <?php
    /**
     * 图片常用处理
     *
     * 需要 yii/yii2-imagine 的支持
     * php composer.phar require --prefer-dist yiisoft/yii2-imagine
     *
     * 文件上传参考文档编写文件上传类
     * @link http://www.yiiframework.com/doc-2.0/guide-input-file-upload.html
     *
     * @author yikai.shao
     */
    namespace appcontrollers;
    
    use ImagineImageManipulatorInterface;
    use yiiimagineImage;
    
    class ImageController extends yiiwebController
    {
        //裁剪
        public function actionCrop()
        {
            Image::crop(‘11.jpg‘, 1000, 1000,[500,500])
            ->save(‘11_crop.jpg‘);
        }
    
    //旋转 public function actionRotate() { Image::frame(‘11.jpg‘, 5, ‘666‘, 0) ->rotate(-8) ->save(‘11_rotate.jpg‘, [‘quality‘ => 50]); } //缩略图(压缩) public function actionThumb() { Image::thumbnail(‘11.jpg‘, 100, 50,ManipulatorInterface::THUMBNAIL_OUTBOUND) ->save(‘11_thumb.jpg‘); } //图片水印 public function actionWatermark() { Image::watermark(‘11.jpg‘, ‘11_thumb.jpg‘, [10,10]) ->save(‘11_water.jpg‘); } //文字水印 //字体参数 the file path or path alias (string) public function actionText() { Image::text(‘11.jpg‘, ‘hello world‘, ‘glyphicons-halflings-regular.ttf‘,[10,10],[]) ->save(‘11_text.jpg‘); } }
  • 相关阅读:
    python内置函数
    conda和anaconda的区别
    闭包,装饰器,property
    【模板】大数乘法(51nod 1027)
    51nod 1791 合法括号子段
    51nod 1419 最小公倍数挑战
    51nod 1241 特殊的排序
    51nod 1090 3个数和为0
    【模板】51nod 1051 最大子矩阵和
    51nod 1267 4个数和为0
  • 原文地址:https://www.cnblogs.com/l-zl/p/6422819.html
Copyright © 2011-2022 走看看