How to Convert Images with an API
Automate image conversion with curl, JavaScript, or Python
Why Use an Image Conversion API
Browser-based converters are great for one-off tasks, but they don't scale. If you need to convert images in a CI/CD pipeline, process uploads in a CMS, or batch-convert a folder of product photos, you need a programmatic solution.
The iLoveAVIF API lets you convert between AVIF, JPG, PNG, and WebP with a single HTTP request. Send a file, get a converted image back. No SDKs, no dependencies, no browser required.
Getting Started
1. Create an Account
Sign up at iloveavif.com/pricing and subscribe to the Pro plan ($4.99/month). Pro includes 1,000 API requests per day plus unlimited browser conversions.
2. Create an API Key
Go to your Dashboard and click "Create API Key". Give it a descriptive name like "CI Pipeline" or "CMS Integration". Copy the key immediately — it's only shown once.
3. Make Your First Request
The conversion endpoint is POST https://iloveavif.com/api/v1/convert. Send your API key in the X-API-Key header, the image as a multipart file upload, and the target format as a form field.
curl -X POST https://iloveavif.com/api/v1/convert \
-H "X-API-Key: ilav_YOUR_KEY_HERE" \
-F "file=@photo.jpg" \
-F "format=avif" \
-F "quality=75" \
--output photo.avifCode Examples
curl
curl -X POST https://iloveavif.com/api/v1/convert \
-H "X-API-Key: ilav_YOUR_KEY_HERE" \
-F "file=@input.png" \
-F "format=webp" \
-F "quality=80" \
--output output.webpJavaScript (fetch)
const form = new FormData();
form.append("file", fileInput.files[0]);
form.append("format", "avif");
form.append("quality", "60");
const res = await fetch("https://iloveavif.com/api/v1/convert", {
method: "POST",
headers: { "X-API-Key": "ilav_YOUR_KEY_HERE" },
body: form,
});
const blob = await res.blob();
// Use blob.arrayBuffer() to save to disk in Node.js
// Use URL.createObjectURL(blob) for browser previewPython (requests)
import requests
res = requests.post(
"https://iloveavif.com/api/v1/convert",
headers={"X-API-Key": "ilav_YOUR_KEY_HERE"},
files={"file": open("input.png", "rb")},
data={"format": "avif", "quality": "75"},
)
with open("output.avif", "wb") as f:
f.write(res.content)
print(f"Savings: {res.headers['X-Savings']}")Supported Formats
The API supports 16 input/output combinations across four formats:
| Input | AVIF | JPG | PNG | WebP |
|---|---|---|---|---|
| AVIF | ✓ | ✓ | ✓ | ✓ |
| JPG | ✓ | ✓ | ✓ | ✓ |
| PNG | ✓ | ✓ | ✓ | ✓ |
| WebP | ✓ | ✓ | ✓ | ✓ |
Common Use Cases
- CI/CD pipelines — Convert images to AVIF/WebP as part of your build process before deploying to production.
- CMS hooks — Automatically convert uploaded images to optimized formats when content editors add media.
- Batch processing — Loop through a directory of images and convert them all with a shell script.
- Browser applications — Use the API from client-side JavaScript (CORS is enabled) for server-side conversion without WASM overhead.
Ready to automate your image conversions? Get a Pro subscription and start making API requests in minutes.
Get API AccessView Full DocsFrequently Asked Questions
No. The iLoveAVIF API is a standard REST endpoint. You can call it with curl, fetch, requests, or any HTTP client. No SDK or library installation is required.
The API accepts AVIF, JPG, PNG, and WebP as input and can convert to any of those four formats. That gives you 16 possible input/output combinations.
Pro subscribers can make up to 1,000 API requests per day. The limit resets at midnight UTC. Browser-based conversions are separate and unlimited for Pro users.
Yes. The API accepts files up to 10MB and images up to 10 megapixels (width × height). These limits prevent memory issues during server-side processing.
