PixMage
An image proxy that shrinks images on the fly.
- Role
- Author
- Where
- Personal project
- When
- 2026
- Built with
- Python, FastAPI, Pillow, httpx; Cloudflare Workers version in JavaScript
- Links
- Source on GitHub
Problem
Image-heavy pages are slow on poor connections. I wanted a proxy that shrinks images on the way through, in the spirit of Bandwidth Hero.
What I built
A FastAPI service: give it an image URL and it returns a resized, re-encoded version. A second version runs as a Cloudflare Worker.
How it works
- quality=40 switches on SUPER mode: images wider than 850 px are downscaled and quality is lowered toward about half the original size.
- quality=95 switches on DOUBLE mode: a 1.5x upscale with sharpening for crisp text.
- Text and graphics (screenshots, manga, UI) are detected and compressed differently from photos.
- WebP and SVG pass through untouched when nothing needs changing. Optional basic auth; everything is set through environment variables.
curl "http://localhost:3000/compress?url=https://example.com/image.jpg&quality=40&format=webp" Outcome
- On a 431,044-byte JPEG, standard mode returned 115,836 bytes (27%) and SUPER mode 65,564 bytes (15%).