dev-master
9999999-dev https://github.com/moxuandi/yii2-tinypngyii2-tinypng-Description
MIT
The Requires
by moxuandi
extension yii2 tinypng
yii2-tinypng-Description
Tinify API 的PHP客户端, 用于 TinyPNG 和 TinyJPG. Tinify 智能压缩你的图像. 阅读更多内容请看官网., (*1)
使用 composer 下载:, (*2)
# 2.2.x(yii >= 2.0.24): composer require moxuandi/yii2-tinypng:"~2.2.0" # 开发版: composer require moxuandi/yii2-tinypng:"dev-master"
params
中添加 api key:'tinyPngApiKeys' => [ 'vMClPPpGgT1WQ5nX7kmdrV5nWW7r6q9V', 'Qg24qhk1xcxGsHvkfWZn4mMNkq64QqX8', 'vk07xRY61h3LThY4BXyYLpHmHdvCvnvZ', 'Y2bLBFbGwJ5w1JvPCj7BY68Jt0GzXTvz', '687t8JHGJBTq5rYC7tJ34jxxs5swWxCt', // …… ],
$tiny = new TinyImage(); $resize = [ 'method' => 'thumb', 'width' => 150, 'height' => 100, ]; // 压缩单个文件: $tiny->compressImage('example.png', 'thumb.png'); // 压缩多个文件: $images = [ 'example1.png' => 'thumb1.png', 'example2.png' => 'thumb2.png', 'example3.png' => 'thumb3.png', // …… ]; $tiny->compressImages($images); # 压缩整个目录(相对目录或绝对目录): $source = Yii::getAlias('@webroot/uploads/image'); $target = Yii::getAlias('@webroot/upload/image'); $tiny->compressFile($source, $target, [], $resize);
yii2-tinypng-Description
MIT
extension yii2 tinypng