Use the free browser image compressor, or send an image to POST /api/compress-image from curl, Python, or an AI agent.
Images are often among the heaviest resources on a webpage. Every kilobyte you shave off can mean faster load times, lower bandwidth use, and a better mobile experience. Running image optimization locally can also mean installing native encoders, wrestling with build tools, and adding another CI step.
What if you could just POST an image and get back a compressed version β no local tooling required?
Agent Media Tools offers a free image compression API at POST /api/compress-image that takes JPEG, PNG, or WebP input and returns JSON with the size savings and a temporary download URL. No signup is required for basic use.
Compressing images server-side has several advantages over local tools:
| Property | Value |
|---|---|
| Endpoint | POST /api/compress-image |
| Input | Multipart/form-data with file field image |
| Optional params | quality (1β100; default 70) |
| Response | JSON with originalSize, compressedSize, savingsPercent, and downloadUrl |
| Max file size | 20 MB |
| Auth | Not required for basic use |
You send an image file, optionally choose a quality level, and receive a temporary URL for the processed result. The endpoint preserves the source format. To change formats, use the separate image converter.
π‘ Windows users: Run these from Git Bash or WSL β PowerShell's curl is an alias for Invoke-WebRequest. Or use Invoke-RestMethod with the same URL/body.
curl -X POST https://agentmediatools.com/api/compress-image \ -F "image=@photo.jpg" \ -F "quality=70"
The JSON response includes the measured savings and a downloadUrl. Open that URLβor fetch it in a second requestβto save the compressed image.
curl -X POST https://agentmediatools.com/api/compress-image \ -F "image=@photo.jpg" \ -F "quality=30"
Quality 30 is aggressive and may introduce visible artifacts. Compare the returned size metadata and inspect the result before using it for a production asset.
Compression preserves the input format. Use the free image converter when you want PNG or JPEG input converted to WebP or AVIF.
Using the built-in requests library (no special SDK needed):
import requests
url = "https://agentmediatools.com/api/compress-image"
files = {"image": open("screenshot.png", "rb")}
data = {"quality": 75}
resp = requests.post(url, files=files, data=data)
resp.raise_for_status()
result = resp.json()
download = requests.get(
"https://agentmediatools.com" + result["downloadUrl"]
)
download.raise_for_status()
with open("screenshot-compressed.png", "wb") as f:
f.write(download.content)
print(f"Saved {result['savingsPercent']}%")
import requests
import os
from pathlib import Path
url = "https://agentmediatools.com/api/compress-image"
input_dir = Path("./images")
output_dir = Path("./images-compressed")
output_dir.mkdir(exist_ok=True)
for img_path in input_dir.glob("*.png"):
with open(img_path, "rb") as f:
resp = requests.post(
url,
files={"image": f},
data={"quality": 70}
)
resp.raise_for_status()
result = resp.json()
download = requests.get(
"https://agentmediatools.com" + result["downloadUrl"]
)
download.raise_for_status()
out_path = output_dir / img_path.name
with open(out_path, "wb") as f:
f.write(download.content)
print(f"{img_path.name}: {result['savingsPercent']}% saved")
This script walks every PNG in ./images, compresses it at quality 70, then downloads the result while preserving the PNG format.
There's no separate SDK package to install β just use Python's built-in requests library as shown above. The compression endpoint is a standard REST API, so any HTTP client works. For MCP-based IDEs like Claude Desktop, install the MCP extension instead.
The official amt CLI has a built-in compress command:
# Install npm install -g agentmediatools-cli # Compress an image amt image compress photo.jpg --quality 70 # Output: Success: Compressed β <temporary-name>.jpg (... KB, saved ...%)
The CLI handles file upload, safe output creation, and auto-naming. Add --json for shell scripts and agents; failures return a nonzero exit code.
If you use Claude Desktop, Cursor, or any MCP-compatible IDE, you can install the Agent Media Tools MCP server and compress images directly from your chat:
# In Claude, just say: "Compress this image: https://example.com/photo.jpg" # Or specify quality: "Compress this image at quality 50: https://example.com/banner.png"
The MCP server exposes compress_image as a tool. Claude handles the file download, uploads it to the API, and returns the compressed result β all without you writing a single line of code.
Results depend on the source format, image complexity, previous optimization, dimensions, and chosen quality. A camera JPEG and a flat-color PNG can behave very differently. The API reports originalSize, compressedSize, and savingsPercent for every request, so your workflow can use measured results instead of assuming a fixed percentage.
The compression API works seamlessly with platforms like n8n, Make, and Zapier via HTTP Request nodes:
https://agentmediatools.com/api/compress-image with the file as multipart form datadownloadUrl, then save or deliver the resultThe first request returns metadata and a temporary download URL. Automation tools can feed that URL into a second HTTP node before uploading the file to storage.
The image compression API can be tried without an account within the shared anonymous limit of 10 tool calls per day. A free login raises the shared limit to 25 calls per day, while Pro provides 1,000 calls per day. See the current pricing page for route-specific upload and credit limits.
Rate limits reset at midnight UTC. The response header X-RateLimit-Remaining tells you how many requests you have left.
Agent Media Tools offers a full suite of image processing APIs:
Grab any JPEG or PNG image and run the curl command above. The response reports the measured savings and gives you a temporary download URL. No account, API key, or credit card is required for basic use.
β Visit Agent Media Tools Β· π API Docs Β· π¬ Discord
Tags: image compression, WebP, JPEG optimization, free API, image processing
Related: Compress images free β Β· Agent skill β Β· Resize β Β· All image tools β