Media

Single-Endpoint Image Optimizer

Compress and optimize images with intelligent format conversion, smart resizing, and EXIF metadata stripping. Supports JPEG, PNG, and WebP.

POST /api/optimize-image
<500ms
API Key

What makes this API special?

A single endpoint that handles all your image optimization needs. Upload any image format (JPEG, PNG, WebP) and get back a perfectly optimized version with detailed compression statistics. Convert between formats or let the API auto-select WebP for maximum web performance.

How It Works

The Image Optimizer API uses SkiaSharp for high-performance image processing, delivering lightning-fast optimization with sub-500ms response times for typical images. The API intelligently analyzes each image and applies the most appropriate optimization techniques.

Key Features

  • Multi-format support: Accepts JPEG, PNG, and WebP input formats
  • Smart format conversion: Convert between JPEG, PNG, and WebP, or use auto to let the API choose the best format
  • Intelligent resizing: Specify target dimensions with automatic aspect ratio preservation
  • EXIF stripping: Remove metadata to reduce file size and protect privacy
  • Compression stats: Get detailed before/after metrics including savings percentage

Code Examples

curl -X POST https://api.atomicapis.dev/api/optimize-image \
  -H "X-RapidAPI-Proxy-Secret: YOUR_SECRET" \
  -H "Content-Type: application/json" \
  -d '{
    "image": "iVBORw0KGgo...",
    "outputFormat": "webp",
    "quality": 80,
    "maxWidth": 800,
    "maxHeight": 600,
    "stripMetadata": true
  }'

Request Parameters

Parameter Type Required Description
image string Yes Base64 image data.
outputFormat string No Output format: jpeg, png, webp, or auto. Default: auto (prefers WebP; keeps PNG for transparent images).
quality integer No Compression quality (1-100). Higher = better quality, larger file. Default: 80.
maxWidth integer No Maximum output width in pixels. Aspect ratio preserved.
maxHeight integer No Maximum output height in pixels. Aspect ratio preserved.
stripMetadata boolean No Remove EXIF/metadata (GPS, camera info, etc.). Default: true.

Response Format

200 OK - Successful optimization
{
  "base64Image": "UklGR...",
  "outputFormat": "webp",
  "originalSizeBytes": 245000,
  "optimizedSizeBytes": 48200,
  "compressionRatio": 0.8033,
  "originalWidth": 1920,
  "originalHeight": 1080,
  "outputWidth": 800,
  "outputHeight": 450
}
Field Type Description
base64Image string Base64-encoded optimized image data.
outputFormat string Output format of the optimized image.
originalSizeBytes integer Original file size in bytes.
optimizedSizeBytes integer Optimized file size in bytes.
compressionRatio number Compression savings as a fraction (1 - optimized/original). Higher means more savings.
originalWidth integer Original image width in pixels.
originalHeight integer Original image height in pixels.
outputWidth integer Output image width in pixels.
outputHeight integer Output image height in pixels.

Use Cases

Web Optimization

Automatically convert uploaded images to WebP for faster page loads. Reduce bandwidth costs and improve Core Web Vitals scores.

E-commerce CMS

Mobile Apps

Resize and compress images before upload to save user data and reduce server storage. Perfect for social apps and photo sharing platforms.

iOS Android

Storage Reduction

Batch process existing image libraries to reclaim storage space. Strip EXIF data for privacy compliance while reducing file sizes by 70-90%.

Archival Backup

Build Constraints

Technical Implementation

  • Built on SkiaSharp for high-performance image processing
  • Sub-500ms processing time for typical images (<5MB)
  • Shared infrastructure with OG Image Gen API for efficiency

Format Support

  • Input: JPEG, PNG, WebP
  • Output: JPEG, PNG, WebP
  • Max size: 10MB per image
Processing time varies based on image size, format conversion complexity, and target dimensions.

Error Codes

Code Status Description
400 Bad Request Invalid image data or malformed request.
401 Unauthorized Missing or invalid API key.
413 Payload Too Large Image exceeds 10MB size limit.
415 Unsupported Media Type Image format not supported.
422 Unprocessable Entity Invalid parameters (e.g., quality > 100).
429 Too Many Requests Rate limit exceeded.
500 Internal Server Error Processing error. Retry with exponential backoff.

Ready to optimize your images?

Start compressing and converting images with a single API call. Get your API key and start building today.