Image Optimization API
Compress, resize, and convert images on the fly. Upload a file or pass a URL. WebP, AVIF, JPEG, PNG output. Powered by Sharp.
Quick Start
# Upload & optimize
curl -X POST https://batian.icu/api/v1/image \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "file=@photo.jpg" \
-F "width=800" \
-F "format=webp" \
-F "quality=85" \
-o optimized.webp
# Optimize from URL
curl -X POST https://batian.icu/api/v1/image \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"url": "https://example.com/photo.jpg", "width": 800, "format": "webp"}' \
-o optimized.webp
Features
Smart Compression
Typically 60-80% size reduction with minimal quality loss. Response includes X-Savings-Percent header.
WebP & AVIF Support
Convert to next-gen formats. WebP is 25-35% smaller than JPEG. AVIF is even smaller. Full browser support.
Resize & Fit
Set width, height, or both. Aspect ratio preserved by default. No enlargement option prevents upscaling artifacts.
URL or Upload
Upload directly via multipart form, or pass a URL to an existing image. Both paths protected by SSRF filtering.
Use Cases
๐ Web Performance โ Auto-convert user uploads to WebP/AVIF. Serve smaller images, improve Lighthouse scores, reduce bandwidth.
๐ฑ Responsive Images โ Generate multiple sizes from one source image. Thumbnail, medium, and full-size variants in one pipeline.
๐ E-Commerce โ Standardize product images. All same width, same format, same quality. Consistent catalog at scale.
๐ธ User-Generated Content โ Accept any image from users, return optimized output. No Sharp setup, no image processing code.
Parameters
| Parameter | Type | Description |
|---|---|---|
file | file (multipart) | Image file to upload (max 10MB) |
url | string | URL of image to download and optimize |
width | integer | Resize to width (preserves aspect ratio) |
height | integer | Resize to height (preserves aspect ratio) |
format | string | Convert to: webp, avif, jpeg, png |
quality | integer | Quality 1-100 (default 80) |
Start optimizing images now
100 free optimizations every month. No credit card. Instant API key.
Get Free API Key