Resizing images programmatically is one of those tasks that comes up constantly โ whether you're building a thumbnail pipeline, optimizing images for a website, or processing uploads in a script. You could install ImageMagick, Sharp, or Pillow. But what if you just want one command that works everywhere?
The Agent Media Tools resize API lets you resize any
publicly accessible image with a single curl call. No SDK. No signup. No API key.
It handles JPEG, PNG, WebP, and AVIF, supports exact pixel dimensions and percentage
scaling, and gives you control over output quality.
Here's every pattern you need โ from a simple thumbnail downscale to advanced batch scripts.
The resize endpoint is a straightforward GET request:
GET https://agentmediatools.com/api/tool/resize-image?image_url={url}&width={w}&height={h}
You pass a public image URL, specify your target dimensions, and get the resized image back as the response body. That's it.
Set width and height in pixels. The image is stretched to fit โ
use this when you know the exact canvas size you need.
curl "https://agentmediatools.com/api/tool/resize-image?image_url=https://example.com/photo.jpg&width=800&height=600" \ --output resized.jpg
This downloads the image at 800ร600 pixels, exactly.
Supply both width and height if you need an exact fit. If you only supply one dimension, the other dimension scales proportionally โ great for keeping aspect ratios.
Instead of exact pixels, use percent to scale by a percentage of the original.
This preserves the aspect ratio automatically.
# Scale to 50% of original size curl "https://agentmediatools.com/api/tool/resize-image?image_url=https://example.com/photo.jpg&percent=50" \ --output half-size.jpg # Scale to 200% (enlarge) curl "https://agentmediatools.com/api/tool/resize-image?image_url=https://example.com/photo.jpg&percent=200" \ --output double-size.jpg
The percent parameter overrides width and height if set.
Values below 100 shrink the image; values above 100 enlarge it.
Enlarging (upscaling) a raster image means the API must interpolate new pixels from existing ones. The result won't look as sharp as a native high-resolution original. For best quality, start from the largest source image you have and scale down.
Need a PNG instead of a JPEG? WebP for smaller file sizes? AVIF for next-gen compression?
Pass a format parameter:
# JPEG โ PNG curl "https://agentmediatools.com/api/tool/resize-image?image_url=https://example.com/photo.jpg&width=400&height=400&format=png" \ --output thumb.png # JPEG โ WebP (great for web performance) curl "https://agentmediatools.com/api/tool/resize-image?image_url=https://example.com/photo.jpg&width=1200&format=webp" \ --output hero.webp # JPEG โ AVIF (even better compression) curl "https://agentmediatools.com/api/tool/resize-image?image_url=https://example.com/photo.jpg&width=800&format=avif" \ --output compressed.avif
Supported output formats: jpeg, png, webp, avif.
Lossy formats (JPEG, WebP, AVIF) let you trade file size for quality with a
quality parameter from 1 (smallest, worst) to 100 (largest, best). The default is 80.
# High-quality JPEG at 95 curl "https://agentmediatools.com/api/tool/resize-image?image_url=https://example.com/photo.jpg&width=1920&quality=95" \ --output high-quality.jpg # Aggressive compression at 30 (tiny file, visible artifacts) curl "https://agentmediatools.com/api/tool/resize-image?image_url=https://example.com/photo.jpg&width=1920&quality=30" \ --output tiny.jpg
# Grab an image, resize it to a 300px square thumbnail
for url in \
"https://site.com/img1.jpg" \
"https://site.com/img2.jpg" \
"https://site.com/img3.jpg"; do
filename=$(basename "$url")
curl -s "https://agentmediatools.com/api/tool/resize-image?image_url=$url&width=300&height=300" \
--output "thumb-$filename"
done
SOURCE="https://images.example.com/hero.jpg" # Desktop: 1920px wide, WebP, quality 85 curl -s "https://agentmediatools.com/api/tool/resize-image?image_url=$SOURCE&width=1920&format=webp&quality=85" \ --output hero-desktop.webp # Tablet: 1024px wide, WebP, quality 80 curl -s "https://agentmediatools.com/api/tool/resize-image?image_url=$SOURCE&width=1024&format=webp&quality=80" \ --output hero-tablet.webp # Mobile: 480px wide, WebP, quality 75 curl -s "https://agentmediatools.com/api/tool/resize-image?image_url=$SOURCE&width=480&format=webp&quality=75" \ --output hero-mobile.webp
#!/usr/bin/env python3
"""Upload all images in a directory to a public URL, then resize them."""
import subprocess, sys, glob
for path in glob.glob("images/*.jpg"):
# Option A: upload to a public host, then call the API
# Option B: use the Agent Media Tools pipeline (see below)
# If the image is already online:
url = f"https://example.com/uploads/{path.split('/')[-1]}"
out = f"resized/{path.split('/')[-1]}"
subprocess.run([
"curl", "-s",
f"https://agentmediatools.com/api/tool/resize-image",
"--data-urlencode", f"image_url={url}",
"--data-urlencode", "width=640",
"-o", out
])
If you run Claude, Cursor, or any MCP-compatible agent, you can connect the resize tool directly into your agent's toolbox. Set up the MCP server with your API key, and your agent can resize images on the fly โ no curl needed.
The MCP server exposes the resize tool as resize_image. Your agent will
automatically handle fetching the image, applying the resize, and saving the result. It's the
same underlying API โ just accessed through the agent's natural language interface.
Check the MCP setup guide for step-by-step instructions.
The resize API works great in pipelines with other tools. Here are a few common chains:
Ready to try it? You don't need an account. Run any of the curl commands above โ they work immediately.
For higher volumes, format conversion, and MCP agent integration, grab a free API key.
Get Started โ| Parameter | Type | Description |
|---|---|---|
image_url |
string | Public URL of the source image (required) |
width |
integer | Target width in pixels |
height |
integer | Target height in pixels |
percent |
integer | Scale by percentage (overrides width/height) |
format |
string | Output format: jpeg, png, webp, avif (default: source format) |
quality |
integer | 1โ100 (default 80). Lower = smaller file. |
The base URL is https://agentmediatools.com/api/tool/resize-image.
No authentication is required for basic use.
If you have ImageMagick or Sharp installed, you can resize locally. But the API approach wins in several scenarios:
Give it a try. Open your terminal and run one of the commands above. You'll have a resized image in about a second.
โ Eric, building Agent Media Tools
Related: Resize images free โ ยท Compress โ ยท All image tools โ