open20/yii2-image
Composer 安装命令:
composer require open20/yii2-image
包简介
Yii2 extension for image manipulating using Kohana Image Library.
关键字:
README 文档
README
Simple to use Yii2 Framework extension for image manipulating using powerful Kohana Image Library. Inspired by old yii extension http://www.yiiframework.com/extension/image/ and Kohana Image Library https://github.com/kohana/image
Installation
Install as a composer package
Use this method to get continuous updates.
composer require yurkinx/yii2-image
or include the dependency in the composer.json file:
{
"require": {
"yurkinx/yii2-image": "^1.2"
}
}
Configuration
In config file
/config/web.php
Add image component
'components' => array(
...
'image' => array(
'class' => 'yii\image\ImageDriver',
'driver' => 'GD', //GD or Imagick
),
)
Usage
$file=Yii::getAlias('@app/pass/to/file'); $image=Yii::$app->image->load($file); header("Content-Type: image/png"); echo $image->resize($width,$height)->rotate(30)->render();
Supported methods out of the box from Kohana Image Library:
$image->resize($width = NULL, $height = NULL, $master = NULL); $image->crop($width, $height, $offset_x = NULL, $offset_y = NULL); $image->sharpen($amount); $image->rotate($degrees); $image->save($file = NULL, $quality = 100); $image->render($type = NULL, $quality = 100); $image->reflection($height = NULL, $opacity = 100, $fade_in = FALSE); $image->flip($direction); $image->background($color, $opacity = 100); $image->watermark(Image $watermark, $offset_x = NULL, $offset_y = NULL, $opacity = 100);
Using resize with resize constrains
$image->resize($width, $height, \yii\image\drivers\Image::HEIGHT); $image->resize($width, $height, \yii\image\drivers\Image::ADAPT)->background('#fff');
Using resize with resize constrains and best quality output image [for Imagick driver only]
Use 1 for best speed and lower quality, 100 for best quality and lower speed. Only values 1,100 currently supported
$image->resize($width, NULL, \yii\image\drivers\Image::WIDTH, 100);
Possible resize constrains:
// Resizing constraints ($master) const NONE = 0x01; const WIDTH = 0x02; const HEIGHT = 0x03; const AUTO = 0x04; const INVERSE = 0x05; const PRECISE = 0x06; const ADAPT = 0x07; const CROP = 0x08;
Using flip with flipping directions
// Flipping directions ($direction) $image->flip(\yii\image\drivers\Image::HORIZONTAL);
Possible flipping directions:
const HORIZONTAL = 0x11; const VERTICAL = 0x12;
open20/yii2-image 适用场景与选型建议
open20/yii2-image 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.54k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 11 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「image」 「extension」 「yii2」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 open20/yii2-image 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 open20/yii2-image 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 open20/yii2-image 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A custom URL rule class for Yii 2 which allows to create translated URL rules
Yii2 LightBox image galary widget uses Lightbox v2.10.0 by Lokesh Dhakar
The Yii2 extension uses jQuery jquery.carousel-1.1.min.js and makes image carousel from php array of structure defined.
TYPO3 CMS extension to create gallery content element with preset crop ratios and pagination
UI Kit 3 Extension for Yii2
Adds more BBCode
统计信息
- 总下载量: 2.54k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2024-11-22