A lightweight PHP image resizer
- Run
composer install
- Set up environment variables
- Resize your images
The image resizer is intended to live as a standalone microservice behind a CDN. The first request for a query combination http://resizer-url.com/resize/?source=http://image-source.com/images/image.jpg&height=300&width=400
will fall through to the resizer instance but any subsequent requests should be cached by the CDN.
The resizer depends on a few configurable environment variables (can be loaded from a dotenv file):
ALLOWED_HOSTS
- a comma separated string of whitelisted domainsCACHE_EXPIRATION_HOURS
- length (in hours) to setCache-Control
with themax-age
directive andExpires
headers. Any CDN should obey your cache rules and cache objects appropriately.APP_ENV
- app environment
In light of exploits like https://imagetragick.com/, we recommend that your implementation:
- Uses the latest version of ImageMagick
- Follows mitigation procedures listed on https://imagetragick.com/
- Has severely restricted access to any other resources (on the same network or otherwise)
- Only processes images from sources you whitelist
healthcheck.php
will return a 200 for Load Balancer health pings.
Run phpunit