March 6, 2026 · 10 min read · Practical Guide

5 Ways to Automate Image Processing with AI APIs

Manual image editing doesn't scale. Whether you're running an e-commerce store with 10,000 product photos or building a content platform that handles user uploads, you need automated image processing that just works.

Modern AI APIs have replaced fragile OpenCV pipelines and expensive Photoshop actions. Here are five image processing tasks you can fully automate today using the PixelAPI Python SDK — each with real code you can drop into your project.

pip install pixelapi
from pixelapi import PixelAPI
client = PixelAPI()  # reads PIXELAPI_KEY from env

1 Background Removal

The most common image processing task in e-commerce, design tools, and social media apps. AI-powered background removal handles hair, transparency, complex edges, and even semi-transparent objects like glass — all in under a second.

Before
Product photo with cluttered studio background, shadows, and reflections on the surface.
After
Clean isolated product on transparent background with precise edge detection — even around fine details like straps and handles.
Python
import os
from pathlib import Path

input_dir = Path("product_photos/")
output_dir = Path("product_photos_clean/")
output_dir.mkdir(exist_ok=True)

for img_path in input_dir.glob("*.jpg"):
    result = client.image.remove_background(
        image=str(img_path),
        output_format="png",
        refine_edges=True       # extra edge refinement
    )
    result.save(output_dir / f"{img_path.stem}.png")
    print(f"✓ {img_path.name} → background removed")
Pro tip: Set refine_edges=True for product photography — it adds a slight feathering that prevents harsh cutout artifacts. For flat graphic assets, leave it off for pixel-perfect edges.

2 Image Upscaling

Low-resolution thumbnails, user-uploaded images, and legacy assets all need upscaling. AI upscaling doesn't just enlarge — it reconstructs detail, sharpens textures, and removes compression artifacts. The result looks like a natively high-resolution image.

Before
256×256 thumbnail with visible JPEG compression artifacts, blurry text, and soft edges.
After
1024×1024 crisp image with reconstructed detail — sharp text, clean edges, and natural texture where there was none before.
Python
# Upscale a single image
result = client.image.upscale(
    image="low_res_hero.jpg",
    scale=4,                  # 2x or 4x
    model="real-esrgan",
    denoise_strength=0.5      # 0.0-1.0, helps with JPEG artifacts
)
result.save("hero_4x.png")
print(f"Upscaled to {result.width}x{result.height}")
Python — Batch
# Batch upscale with async for speed
import asyncio
from pixelapi import AsyncPixelAPI

async def upscale_batch(image_paths, scale=4):
    async_client = AsyncPixelAPI()
    tasks = [
        async_client.image.upscale(image=str(p), scale=scale)
        for p in image_paths
    ]
    results = await asyncio.gather(*tasks)
    for path, result in zip(image_paths, results):
        result.save(f"upscaled/{path.stem}_{scale}x.png")
    return len(results)

paths = list(Path("thumbnails/").glob("*.jpg"))
count = asyncio.run(upscale_batch(paths))
print(f"Upscaled {count} images")

3 Face Restoration

Old family photos, low-quality video frames, compressed social media images — face restoration brings faces back to life. It reconstructs facial features, sharpens skin texture, and corrects artifacts while keeping the person recognizable.

Before
Heavily compressed or aged photo with blurred facial features, noise, and color degradation.
After
Restored face with clear eyes, natural skin texture, and sharp features — the person is recognizably the same but the photo looks decades newer.
Python
# Restore faces in a photo
result = client.image.restore_face(
    image="old_family_photo.jpg",
    model="codeformer",
    fidelity=0.7,            # 0.0 = max quality, 1.0 = max fidelity to original
    upscale=2                # optionally upscale while restoring
)
result.save("family_restored.png")

# Works great in a pipeline with upscaling
upscaled = client.image.upscale(image=result.image_bytes, scale=2)
upscaled.save("family_restored_4x.png")
Fidelity vs Quality trade-off: Lower fidelity values produce sharper, more "perfect" faces but may alter features slightly. Higher values stay truer to the original but with less enhancement. Start at 0.7 and adjust.

4 Object Removal (Inpainting)

Remove unwanted objects, watermarks, people in the background, or blemishes — and the AI fills in the gap with contextually appropriate content. No manual clone-stamping needed.

Before
Beautiful architectural photo with a distracting trash can in the foreground and tourists in the background.
After
Same photo with the trash can and tourists cleanly removed — the pavement and background filled in seamlessly with matching texture and perspective.
Python
# Remove an object using a mask
result = client.image.inpaint(
    image="architecture_photo.jpg",
    mask="mask.png",            # white = remove, black = keep
    prompt="clean stone pavement, same lighting and perspective",
    model="flux-schnell",
    strength=0.85
)
result.save("architecture_clean.png")
Python — Auto-detect & remove
# Or describe what to remove — no mask needed
result = client.image.remove_object(
    image="architecture_photo.jpg",
    object_prompt="trash can in the foreground",
    fill_prompt="stone pavement matching surroundings"
)
result.save("architecture_clean.png")

The mask-free approach uses an internal segmentation model to identify the object before inpainting. For production use with consistent results, provide explicit masks.

5 Style Transfer

Transform photos into artistic styles — watercolor, oil painting, anime, pixel art, pencil sketch — while preserving composition and structure. Perfect for content variation, social media, and creative tools.

Before
Standard smartphone photo of a city street with buildings, pedestrians, and natural lighting.
After
Same scene rendered as a Studio Ghibli-style watercolor illustration — warm palette, soft edges, whimsical atmosphere, but the same composition and recognizable landmarks.
Python
# Apply style transfer
result = client.image.style_transfer(
    image="city_street.jpg",
    style="ghibli-watercolor",    # preset style
    strength=0.75,                # how much to stylize (0.0-1.0)
    preserve_structure=True       # keep composition intact
)
result.save("city_ghibli.png")
Python — Custom style from reference
# Use a reference image as the style source
result = client.image.style_transfer(
    image="city_street.jpg",
    style_image="van_gogh_starry_night.jpg",  # reference
    strength=0.6,
    preserve_structure=True
)
result.save("city_vangogh.png")

Available preset styles include: ghibli-watercolor, oil-painting, anime, pixel-art, pencil-sketch, comic-book, low-poly, and cyberpunk. Or use any image as a style reference.

Putting It All Together: A Complete Pipeline

Here's a real-world example — an e-commerce image pipeline that processes raw product photos into web-ready assets:

from pixelapi import PixelAPI
from pathlib import Path

client = PixelAPI()

def process_product_image(input_path: str, output_dir: str = "processed"):
    """Full product image pipeline: remove BG → restore → upscale"""
    out = Path(output_dir)
    out.mkdir(exist_ok=True)
    stem = Path(input_path).stem

    # Step 1: Remove background
    no_bg = client.image.remove_background(
        image=input_path,
        output_format="png",
        refine_edges=True
    )

    # Step 2: Face restoration (if applicable — e.g. model wearing product)
    restored = client.image.restore_face(
        image=no_bg.image_bytes,
        fidelity=0.8
    )

    # Step 3: Upscale to 2x for retina displays
    final = client.image.upscale(
        image=restored.image_bytes,
        scale=2
    )

    final.save(out / f"{stem}_final.png")
    print(f"✓ {stem}: {final.width}x{final.height}")
    return final

# Process all product photos
for photo in Path("raw_products/").glob("*.jpg"):
    process_product_image(str(photo))

Further Reading

Automate Your Image Pipeline

100 free API calls per day. Process thousands of images with a few lines of Python.

Get Started Free →