nicklog/imgproxy
Composer 安装命令:
composer require nicklog/imgproxy
包简介
This library provides a simple way to generate URLs for imgproxy.
README 文档
README
ImgProxy
This is a PHP library that makes it easy to build URL for ImgProxy.
Installation
The preferred way to install this extension is through composer.
Either run
composer require nicklog/imgproxy:^1.0
or add this code line to the require section of your composer.json file:
"nicklog/imgproxy": "^1.0"
Usage
use NickLog\ImgProxy\ImgProxy; use NickLog\ImgProxy\Signer\KeyPair; use NickLog\ImgProxy\Options\Dpr; use NickLog\ImgProxy\Options\Quality; use NickLog\ImgProxy\Options\Width; use NickLog\ImgProxy\Options\Height; $imgProxyBaseUrl = 'https://imgproxy.example.com'; $key = getenv('IMGPROXY_KEY'); $salt = getenv('IMGPROXY_SALT'); $src = 'http://example.com/image.jpg'; $signer = new KeyPair($key, $salt); $imgProxy = new ImgProxy($imgProxyBaseUrl, $signer); $builder = $imgProxy->urlBuilder($src); $builder = $builder->with( new Dpr(2), new Quality(90), new Width(300), new Height(400) ); $url = $builder->build()->__toString(); // encoded url $url = $builder->encoded(false)->build()->__toString(); // plain url # example: /9SaGqJILqstFsWthdP/dpr:2/q:90/w:300/h:400/aHR0cDovL2V4YW1w/bGUuY29tL2ltYWdl/LmpwZw
License
Released under the MIT license.
统计信息
- 总下载量: 210
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-12-29