记录yii2-imagine几个常用方法:
//压缩 Image::thumbnail('@webroot/img/test-image.jpg', 120, 120)->save(Yii::getAlias('@webroot/img/thumb-test-image.jpg'), ['quality' => 100]); echo Yii::getAlias('@webroot/img/thumb-test-image.jpg'); //剪切 //$result = Image::crop('@webroot/img/test-image.jpg', 200, 200,[100,100])->save('E:/phpWork/yii2.0/frontend/web/img/thumb-test-crop.jpg'); $result = Image::crop('@webroot/img/test-image.jpg', 200, 200,[100,100])->save(Yii::getAlias('@webroot/img/thumb-test-crop.jpg')); //旋转 Image::frame('@webroot/img/test-image.jpg', 5, '666', 0)->rotate(-8)->save(Yii::getAlias('@webroot/img/thumb-test-frame.jpg'), ['quality' => 100]); //水印 Image::watermark('@webroot/img/test-image.jpg', '@webroot/img/watermark.jpg', [10,10])->save(Yii::getAlias('@webroot/img/thumb-test-watermark.jpg'), ['quality' => 100]); //文字水印 Image::text('@webroot/img/test-image.jpg', 'hello world', '@webroot/img/symbol.ttf',[100,100],['color'=>'000000','size'=>50])->save(Yii::getAlias('@webroot/img/thumb-test-text.jpg'), ['quality' => 100]);