whagency/yii2-imagecache
最新稳定版本:1.0.4
Composer 安装命令:
composer require whagency/yii2-imagecache
包简介
Yii2 image cache
README 文档
README
Yii2 extension for generating images based on Imagick
Capabilities
- FIT - resize image WITH proportion and based on BOTH sides
- Scale - resize image WITH proportion and based on ONE sides
- Crop - crop image WITH proportion
- Generate black-and-white image
- Add watermark to the image
- Add background color for FITed images
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require "whagency/yii2-imagecache" "*"
or add to your composer.json file
"require": { "whagency/yii2-imagecache": "*" },
Config
'components' => [ ... 'imageCache' => [ 'class' => 'webheads\imagecache\imageCache', 'cachePath' => '@app/web/files/cache', 'cacheUrl' => '@web/files/cache', ], ]
Usage Example PHP 8.0
Yii::$app->imageCache->img('/files/image.jpg', imagick_options: ['fit' => 300, 'bg' => '#ff0000', 'watermark' => '@app/web/files/images/wmk.png']) // Result: image 300 x 300 without cropping, with watermark and background color.
Usage Example
echo Yii::$app->imageCache->imgSrc('@app/web/files/image.jpg', '', ['fit' => 300, 'bw' => true, 'watermark' => '@app/web/files/watermark-image.png']); // Result: path to black-and-white image 300 x 300 without cropping, with watermark. echo Yii::$app->imageCache->img('@app/web/files/image.jpg', '400x', ['class'=>'my-class', 'alt' => 'Image']); // Result: scaled image with width = 400, alt and class. echo Yii::$app->imageCache->img('@app/web/files/image.jpg', '100x150', ['alt' => 'Image'], ['bw' => true]); // Result: resized and cropped black-and-white image 100 x 150 with alt.
统计信息
- 总下载量: 647
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-06-20