A production-grade cloud-based image resizing system built with AWS serverless architecture. Upload images and instantly generate optimized variants at multiple sizes and formats.
- Image upload with drag-and-drop or file picker
- AI Image Detection โ Automatically analyzes EXIF metadata and structural signatures to determine if an uploaded image is AI-generated (e.g., Midjourney, DALL-E) and flags it in the UI with a confidence score.
- Automatic resizing into preset sizes:
- ๐น Thumbnail: 100ร100
- ๐น Medium: 300ร300
- ๐น Large: 800ร800
- Format conversion (JPEG, PNG, WebP) with compression optimization
- Dynamic resizing via API โ custom width, height, and format
- Pre-signed S3 upload URLs for secure direct-to-S3 uploads
- CloudFront CDN delivery for fast global access
- S3 event-driven processing via AWS Lambda
- Dual-mode architecture โ works locally and on AWS with a single env toggle
- Upload progress tracking with visual progress bar
- Image history with recent uploads gallery
- Image history with recent uploads gallery (optimized thumbnails)
- Copy-to-clipboard for all variant URLs
- Structured logging and request metadata (ID, timing)
โโโโโโโโโโโโโโโโ
Browser / Client โโโโโโโโโโโบ โ API Gateway โ
โ โโโโโโโโฌโโโโโโโโ
โ โ
โ (pre-signed URL) โผ
โโโโโโโโโโโโโโโโโโโโบ โโโโโโโโโโโโโโโโ
โ S3 Input โ
โ Bucket โ
โโโโโโโโฌโโโโโโโโ
โ (S3 event trigger)
โผ
โโโโโโโโโโโโโโโโ
โ Lambda โ
โ (Pillow) โ
โโโโโโโโฌโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโ
โ S3 Output โ
โ Bucket โ
โโโโโโโโฌโโโโโโโโ
โ
โผ
โโโโโโโโโโโโโโโโ
โ CloudFront โ
โ CDN โ
โโโโโโโโโโโโโโโโ
| Service | Purpose |
|---|---|
| Amazon S3 | Image storage (input + output buckets) |
| AWS Lambda | Event-driven image processing |
| API Gateway | REST API with validation and throttling |
| CloudFront | CDN for fast global image delivery |
| CloudWatch | Monitoring, logging, and alerting |
โโโ backend/
โ โโโ app/
โ โ โโโ main.py # FastAPI application with all endpoints
โ โ โโโ config.py # Configuration with dual-mode (local/S3)
โ โ โโโ schemas.py # Pydantic request/response models
โ โ โโโ lambda_handler.py # AWS Lambda S3 event handler
โ โ โโโ services/
โ โ โโโ image_service.py # Core image processing
โ โ โโโ s3_service.py # S3 operations wrapper
โ โ โโโ metadata_service.py # JSON metadata persistence
โ โโโ requirements.txt
โ โโโ lambda_requirements.txt
โ โโโ .env # Environment configuration (ignored in VCS)
โ โโโ .env.example # Template (safe for VCS)
โโโ frontend/
โ โโโ src/
โ โ โโโ App.jsx # React UI with glassmorphism theme
โ โ โโโ api.js # API client with progress tracking
โ โ โโโ styles.css # Dark glassmorphism design system
โ โ โโโ main.jsx # Entry point
โ โโโ index.html
โ โโโ package.json
โโโ deploy/
โ โโโ aws-setup.md # Step-by-step AWS deployment guide
โ โโโ iam-policy.json # Least-privilege Lambda IAM policy
โโโ README.md
- Python 3.11+
- Node.js 18+
- (Optional) AWS CLI configured with credentials
cd backend
python -m venv .venv
.venv\Scripts\activate # Windows
# source .venv/bin/activate # macOS/Linux
pip install -r requirements.txt
uvicorn app.main:app --reloadAPI runs at http://127.0.0.1:8000 โ Docs at /docs
cd frontend
npm install
npm run devFrontend runs at http://localhost:5173
All settings use the IMAGE_RESIZER_ prefix and load from backend/.env:
# Storage mode: "local" (development) or "s3" (production)
IMAGE_RESIZER_STORAGE_BACKEND=local
# AWS
IMAGE_RESIZER_AWS_REGION=ap-south-1
IMAGE_RESIZER_AWS_ACCESS_KEY_ID=your-key
IMAGE_RESIZER_AWS_SECRET_ACCESS_KEY=your-secret
# S3 Buckets
IMAGE_RESIZER_S3_INPUT_BUCKET=serverless-image-resizer-buckets-input
IMAGE_RESIZER_S3_OUTPUT_BUCKET=serverless-image-resizer-buckets-output
# CloudFront
IMAGE_RESIZER_CLOUDFRONT_DOMAIN=d1234abcdef.cloudfront.netSwitch from local to AWS by changing IMAGE_RESIZER_STORAGE_BACKEND=s3.
| Method | Endpoint | Description |
|---|---|---|
GET |
/health |
Health check with version and storage backend |
POST |
/upload |
Upload image, run AI detection, and generate preset variants |
GET |
/image/{image_id} |
Fetch image metadata by ID |
GET |
/images?limit=20&offset=0 |
List recent images with pagination |
GET |
/resize?image_id=...&width=...&height=...&format=... |
Create custom-sized variant |
GET |
/presign?filename=...&content_type=... |
Get pre-signed S3 upload URL |
POST |
/confirm-upload |
Confirm S3 upload and trigger processing |
See deploy/aws-setup.md for the complete step-by-step guide with AWS CLI commands to set up:
- S3 input/output buckets with CORS
- Lambda function with IAM role
- S3 โ Lambda event trigger
- API Gateway REST API
- CloudFront CDN distribution
- CloudWatch monitoring alarms
- IAM roles with least-privilege access (policy)
- File type validation โ only JPG, PNG, WebP allowed
- Max file size limit โ 5 MB
- Pre-signed upload URLs โ expire after 5 minutes
- CORS configured for known origins
- Request IDs and timing headers on all responses
- CloudWatch Logs โ structured Lambda execution logs
- CloudWatch Alarms โ error rate and latency alerts
- Request metadata โ every response includes
X-Request-IdandX-Process-Time-Msheaders
| Metric | Target |
|---|---|
| Processing time | < 2 seconds per image |
| CDN latency | < 200 ms |
| Error rate | < 1% |
| Availability | 99.9% |
- AI-based auto-cropping and face detection
- Watermarking
- Batch processing
- Dashboard analytics
- DynamoDB metadata storage