๐Ÿ–ผ๏ธ

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.

Get Free API Key Read Docs

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

ParameterTypeDescription
filefile (multipart)Image file to upload (max 10MB)
urlstringURL of image to download and optimize
widthintegerResize to width (preserves aspect ratio)
heightintegerResize to height (preserves aspect ratio)
formatstringConvert to: webp, avif, jpeg, png
qualityintegerQuality 1-100 (default 80)

Start optimizing images now

100 free optimizations every month. No credit card. Instant API key.

Get Free API Key