FastAPI service for serving and resizing images with on-the-fly resizing via URL parameters.
- Install dependencies:
pip install -r requirements.txt- Configure
.env:
ASSETS_DIR=/path/to/images
CACHE_DIR=./cache
PORT=8001- Run:
uvicorn app.main:app --host 0.0.0.0 --port 8001Original image:
GET /images/path/to/image.jpg
Resized image:
GET /images/path/to/image-1200-800.jpg
Health check:
GET /health
- On-the-fly image resizing
- Disk caching with size limits
- Aspect ratio preservation
- JPEG optimization
- CORS support