编程学习网 > PHP技术 > Yii2 > yii2 图片处理插件Imagine
2019
12-05

yii2 图片处理插件Imagine

yii2 图片处理插件Imagine


use Imagine\Image\ManipulatorInterface;
use yii\imagine\Image;
 
public function actionPhoto()
{
    //剪切
    Image::crop('./image/1.jpg', 1000, 1000,[500,500])
        ->save('./image/1_crop.jpg');
 
 
    //旋转
    Image::frame('./image/1.jpg', 5, '666', 0)
            ->rotate(-8)
            ->save('./image/1_rotate.jpg', ['quality' => 50]);
 
 
    //压缩
    Image::thumbnail('./image/1.jpg', 100, 50,ManipulatorInterface::THUMBNAIL_OUTBOUND)
            ->save('./image/1_thumb.jpg');
 
 
    //图片水印
    Image::watermark('./image/1.jpg', './image/1_thumb.jpg', [10,10])
            ->save('./image/1_water.jpg');
 
 
    //文字水印
     Image::text('./image/1.jpg', 'hello world', 'glyphicons-halflings-regular.ttf',[10,10],[])
            ->save('./image/1_text.jpg');
}


扫码二维码 获取免费视频学习资料

Python编程学习

查 看2022高级编程视频教程免费获取