Skip to main content
GuidePython

Bulk Image Conversion API in Python

Convert hundreds of images to any format (PNG, WebP, JPG, TIFF) in bulk using the Convert Fleet API in Python. Includes concurrent processing example.

LanguagePython
Conversionpngwebp
API ReferenceView Endpoint →

You need an API key to follow this guide. Get a free API key →

1Install Dependencies

Install requests and optionally httpx for concurrent requests.

bash
pip install requests

2Bulk Convert Images

Loop through your image files and convert each one using the Convert Fleet API.

python
import requests
import os
from pathlib import Path

API_KEY = "YOUR_API_KEY"
TO_FORMAT = "webp"  # Change to: png, jpg, tiff, gif, etc.

def convert_image(input_path: str, output_path: str):
    headers = {"Authorization": f"Bearer {API_KEY}"}
    with open(input_path, "rb") as f:
        response = requests.post(
            "https://convertfleet.com/api/convert",
            files={"file": f},
            data={"to": TO_FORMAT},
            headers=headers
        )
    response.raise_for_status()
    with open(output_path, "wb") as out:
        out.write(response.content)

# Bulk convert all PNGs in a folder
input_folder = Path("./images")
output_folder = Path("./images_webp")
output_folder.mkdir(exist_ok=True)

for img_path in input_folder.glob("*.png"):
    output_path = output_folder / f"{img_path.stem}.{TO_FORMAT}"
    print(f"Converting {img_path.name}...")
    convert_image(str(img_path), str(output_path))

print("All images converted!")

That's it!

You've successfully integrated the Convert Fleet API. Check the API reference for the full list of parameters and error codes.

Related API Endpoints

More Integration Guides

Start Building Today

Free tier includes 200 free credits (valid 30 days from signup). Pro plan unlocks unlimited API access.