โ† Back to blog

Build an Automated Image Pipeline: Resize โ†’ WebP โ†’ Deliver

July 7, 2026 ยท Eric ยท 6 min read

One resized image is a chore. A thousand product photos is a pipeline. The difference isn't effort โ€” it's chaining API calls so your agent or cron job runs unattended while you sleep.

This guide walks through a real-world pipeline on Agent Media Tools: ingest images, resize to a standard width, convert to WebP, optionally compress, then deliver via webhook or Discord.

๐Ÿ“ฅ Inputโ†’ ๐Ÿ“ Resizeโ†’ ๐Ÿ”„ WebPโ†’ ๐Ÿ—œ๏ธ Compressโ†’ ๐Ÿ“ค Deliver

Step 1: Resize to Standard Dimensions

curl -X POST https://agentmediatools.com/api/resize-image \
  -F "image=@product-raw.jpg" \
  -F "width=1200" \
  -F "format=webp" \
  -o step1.webp

Setting format=webp on resize combines two steps in one call โ€” resize and convert. For large batches, use POST /api/jobs with batch-resize (Premium) to queue work asynchronously.

Step 2: Compress (Optional)

curl -X POST https://agentmediatools.com/api/compress-image \
  -F "image=@step1.webp" \
  -F "quality=80" \
  -o final.webp

Quality 75โ€“85 is the sweet spot for e-commerce โ€” visually identical, 40โ€“60% smaller files.

Step 3: Python Pipeline Script

import requests, pathlib

BASE = "https://agentmediatools.com"
INPUT_DIR = pathlib.Path("products/raw")
OUTPUT_DIR = pathlib.Path("products/webp")
OUTPUT_DIR.mkdir(exist_ok=True)

for img in INPUT_DIR.glob("*.jpg"):
    with open(img, "rb") as f:
        r = requests.post(f"{BASE}/api/resize-image",
            files={"image": f},
            data={"width": "1200", "format": "webp", "quality": "82"},
        )
        r.raise_for_status()
        out = OUTPUT_DIR / (img.stem + ".webp")
        out.write_bytes(r.content)
        print(f"OK {img.name} โ†’ {out.name}")

Run with cron: 0 2 * * * python3 pipeline.py โ€” processes overnight at 2 AM.

Step 4: Webhook on Completion (Premium)

Register a webhook in your account settings. When async jobs finish, Agent Media Tools POSTs the result URL to your endpoint:

POST /api/jobs
{
  "type": "batch-convert",
  "files": [...],
  "webhook_url": "https://yoursite.com/hooks/image-done"
}

Poll GET /api/jobs/:id or wait for the webhook โ€” your agent never blocks on long jobs.

Step 5: Deliver to Discord

After processing, post to a Discord webhook:

curl -X POST "https://discord.com/api/webhooks/YOUR_WEBHOOK" \
  -F "content=Batch complete: 47 images โ†’ WebP" \
  -F "file=@final.webp"

This is the exact flow shown in the homepage demo: Claude โ†’ Resize โ†’ Convert โ†’ Upload โ†’ Discord.

Scaling to 1,000 Images/Day

See pricing for the full breakdown.

Related Reading

Start building: Open Pipeline Builder ยท Go Premium โ€” $5/mo


Built at agentmediatools.com