Pixel-perfect PNG → WebP compression under 400 bytes. Powered by Python Pillow with SHA-256 pixel verification. Built for TDS exam submissions.
| Feature | Description |
|---|---|
| 🎯 Lossless Compression | PNG → WebP with zero pixel loss, verified by SHA-256 hash comparison |
| 📦 < 400 Bytes Output | Compressed files consistently under 400 bytes for exam compliance |
| 🐍 Python Pillow Backend | Server-side compression using lossless=True, quality=100 |
| ⚡ Instant Processing | ~30ms compression via Vercel serverless functions |
| 🔒 Pixel Verification | SHA-256 hash of raw pixel data — before and after — proves lossless |
| 📱 Responsive Design | Dark glassmorphism UI that works on desktop and mobile |
| 🔄 Auto Retry | 2 automatic retries with exponential backoff on network failures |
| 📥 Smart Download | Files download with original name + _by_GauravTomar.webp branding |
→ Try it live on Vercel (deploy your own below)
| Layer | Technology |
|---|---|
| Frontend | Vanilla HTML, CSS, JavaScript |
| Backend | Python 3.9+ with Pillow |
| Deployment | Vercel Serverless Functions |
| Design | Dark glassmorphism, Inter + JetBrains Mono fonts |
tds-image-compressor/
├── api/
│ └── compress.py # Vercel serverless function (production API)
├── index.html # Main application page
├── style.css # Dark glassmorphism theme
├── app.js # Frontend logic with retry & timeout
├── server.py # Local development server
├── vercel.json # Vercel deployment config
├── requirements.txt # Python dependencies (Pillow)
├── .gitignore
├── LICENSE
└── README.md
# Clone the repo
git clone https://github.com/GyaanFlow/tds-image-compressor.git
cd tds-image-compressor
# Install Pillow
pip install Pillow
# Start local server
python server.py
# Open http://localhost:8000Option 1 — One-Click Deploy:
Option 2 — CLI:
npm install -g vercel
vercel login
vercel --prodCompress an image to lossless WebP.
Request:
curl -X POST -F "file=@image.png" https://your-app.vercel.app/api/compressResponse:
{
"success": true,
"compressed_image": "<base64-webp>",
"original": { "size": 7082, "width": 500, "height": 500, "format": "PNG" },
"compressed": { "size": 224, "width": 500, "height": 500, "format": "WebP" },
"validation": {
"size_under_limit": true,
"dimensions_match": true,
"is_lossless": true
},
"compression_ratio_percent": 96.84,
"download_filename": "image.webp",
"processing_ms": 30.7
}Health check endpoint.
{ "status": "ok", "service": "image-compressor", "version": "2.0.0" }Original PNG → Decode to RGBA pixels → SHA-256 hash (A)
↓
Compress to WebP (lossless=True)
↓
WebP output → Decode to RGBA pixels → SHA-256 hash (B)
↓
Hash A == Hash B? → ✅ Pixel-identical!
Every compression is verified by comparing SHA-256 hashes of the raw pixel data before and after. If even one pixel differs, the verification fails.
- Stateless serverless design — scales to lakhs of concurrent users
- Decompression bomb protection — rejects images > 16M pixels
- Memory cleanup — explicit GC-friendly cleanup for serverless
- Security headers —
X-Content-Type-Options,X-Frame-Options,Referrer-Policy - Request timeout — 15s client-side timeout with auto-retry
- Compact JSON — minimized response payloads for faster transfer
Gaurav Tomar — Python Developer
This project is licensed under the MIT License.
Built with 🐍 Python & deployed on ▲ Vercel
© 2025 Gaurav Tomar