tck / zf2-imageresizer
Laminas 的图像缩放和操作模块
v3.0.2
2023-06-28 15:57 UTC
Requires
- php: ^7.2 || ^8.0 || ^8.1 || ^8.2
- imagine/imagine: ^0.6 || ^1.0
- laminas/laminas-cache: ^2.7.1 || ^3.0
- laminas/laminas-config: ^2.6 || ^3.0
- laminas/laminas-http: ^2.5.4
- laminas/laminas-i18n: ^2.7.3
- laminas/laminas-loader: ^2.5.1
- laminas/laminas-log: ^2.9
- laminas/laminas-modulemanager: ^2.7.2
- laminas/laminas-mvc: ^3.0.1
- laminas/laminas-view: ^2.8
Requires (Dev)
- laminas/laminas-serializer: ~2.5
- mikey179/vfsstream: ^1.6.7
- nikic/php-parser: ^4.10
- pdepend/pdepend: 2.*
- phploc/phploc: ^7.0
- phpmd/phpmd: 2.*
- phpunit/phpunit: ^9.5
- sebastian/phpcpd: ^6.0
- squizlabs/php_codesniffer: ^3.5
README
此 Laminas 模块一旦启用,可以通过 URL 进行图像缩放和操作。
要求
- PHP 7.2+
- Laminas MVC
- Imagine
重要!版本说明
- 版本 3.x:Laminas 已停止支持 Zend Framework 3。
- 版本 2.x:Zend Framework 3 已停止支持 Zend Framework 2。
- 版本 1.x:Zend Framework 2
安装
在您的 Laminas 项目中通过 composer 安装
$ composer require tck/zf2-imageresizer
安装后
-
在您的
application.config.php
文件中启用它。<?php return [ 'modules' => ] // ... 'TckImageResizer', ], // ... ];
-
在 "public" 文件夹中创建 "processed" 文件夹。
使用方法
基本语法
公共文件夹中的所有文件
- folder/filename.ext
processed/
folder/filename.$command1,param1,param2$command2
.ext
示例:创建缩略图和灰度图像
- img/logo.jpg
processed/
img/logo.$thumb,160,120$grayscale
.jpg
视图辅助函数
Laminas 模板
<img alt="Example image" src="<?php echo $this->resize('img/logo.jpg')->thumb(200, 160)->grayscale(); ?>" />
渲染的 HTML
<img alt="Example image" src="/processed/img/logo.$thumb,200,160$grayscale.jpg" />
命令列表
- thumb(width, height)
- resize(width, height)
- grayscale
- negative
- gamma(correction)
- colorize(hexColor)
- sharpen
- blur(sigma = 1)
- 404(text = 'Not found', backgroundColor = 'F8F8F8', color = '777777', width = null, height = null) 在视图辅助函数中:->x404(...) [text: url-safe base64] - \TckImageResizer\Util\UrlSafeBase64::encode($text)
可能的自定义命令 - 示例:添加水印(待文档说明)
目标 / 待办事项
- 更多命令
- 更多命令选项
- 管理功能
- 创建占位符