nicklog / imgproxy
This library provides a simple way to generate URLs for imgproxy.
                                    Fund package maintenance!
                                                                            
                                                                                                                                        http://github.com/sponsors/nicklog
                                                                                    
                                                                            
                                                                                                                                        Paypal
                                                                                    
                                                                            
                                                                                                                                        Liberapay
                                                                                    
                                                                
Installs: 88
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/nicklog/imgproxy
Requires
- php: ^8.3
 
Requires (Dev)
- doctrine/coding-standard: ^12.0
 - phpstan/phpstan: ^1.12
 - phpstan/phpstan-deprecation-rules: ^1.2
 - phpstan/phpstan-phpunit: ^1.4
 - phpstan/phpstan-strict-rules: ^1.6
 - phpunit/phpunit: ^11.4
 - roave/security-advisories: dev-master
 - shipmonk/composer-dependency-analyser: ^1.7
 - squizlabs/php_codesniffer: ^3.10
 
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.