nelson/resizer
Composer 安装命令:
composer require nelson/resizer
包简介
Resizer Extension for Nette Framework & Latte
README 文档
README
-
Composer:
composer require nelson/resizer -
Register:
extensions: resizer: Nelson\Resizer\DI\ResizerExtension
-
Config:
This is the bare minimum required:
resizer: library: 'Imagick' # Imagick|Gmagick|Gd wwwDir: %wwwDir% tempDir: %tempDir%
Other options with their defaults:
resizer: interlace: true # for progressive JPEGs strip: true # removes image metadata, color profiles etc. cache: '/resizer/' qualityAvif: 70 # 0 - 100 qualityWebp: 70 # 0 - 100 qualityJpeg: 70 # 0 - 100 compressionPng: 9 # 0 - 9 upgradeJpg2Webp: true # automatically convert JPEGs to WEBP when the format is supported by the browser & server upgradeJpg2Avif: true # automatically convert JPEGs to AVIF when the format is supported by the browser & server upgradePng2Webp: true # automatically convert PNGs to WEBP when the format is supported by the browser & server upgradePng2Avif: true # automatically convert PNGs to AVIF when the format is supported by the browser & server
There is also an upgrade/downgrade logic for AVIF & WEBP. Most preferred is the original AVIF/WEBP, then each other, finally JPEG.
AVIF is preferred over WEBP in case both upgrades are enabled.
Usage
Order of parameters is dependant on the router, the default is:
- Dimensions & modifiers.
string - Image file.
string - Format.
string
Dimensions & modifiers
Syntax:
- [ifresize-][[cropX]width]x[[cropY]height][forceDimensions][-quality]
Dimensions:
100x100- width and height must be equal or less, resized according to AR.x100- height must be equal or less.100x- width must be equal or less.100x50!- dimensions are forced without respecting ifresize and AR.- Cropping:
- width:
l- left,c- center,r- right. - height:
t- top,c- center,b- bottom. - Example:
c100xc100
- width:
Modifiers:
ifresize- Example:
ifresize-100x200 - If the image is smaller than the desired width and/or height, image will not be enlarged.
- Example:
- Quality
- Example:
x-q50- sets just the quality without any resize. - For WEBP/AVIF quality set to
100means lossless compression.
- Example:
Format:
- The format parameter can be used to switch between image file formats, e.g.
<source srcset="">in<picture>tag for converting jpegs to WEBP/AVIF.
Relative and absolute URLs
Relative:
<img src="{rlink 'test.jpg', '200x100'}">
Absolute, uses diffent tag:
<img src="{rlinkabs 'test.jpg', 'l400xc200'}"><a href="{rlinkabs 'test.jpg', 'l400xc200'}" target="_blank">Link to image</a>
nelson/resizer 适用场景与选型建议
nelson/resizer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.92k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2018 年 01 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 nelson/resizer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 nelson/resizer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.92k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 14
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2018-01-08