Copyable requests
curl
curl -F "image=@photo.jpg" \
-F "quality=70" \
https://agentmediatools.com/api/compress-image
JavaScript
import { readFile } from "node:fs/promises";
const form = new FormData();
form.append("image", new Blob([await readFile("photo.jpg")]), "photo.jpg");
form.append("quality", "70");
const res = await fetch("https://agentmediatools.com/api/compress-image", {
method: "POST",
body: form
});
console.log(await res.json());
Python
import requests
with open("photo.jpg", "rb") as image:
response = requests.post(
"https://agentmediatools.com/api/compress-image",
files={"image": image},
data={"quality": 70},
)
print(response.json())
Example JSON response
{
"success": true,
"originalSize": 4281042,
"compressedSize": 621884,
"savingsPercent": 85,
"downloadUrl": "/downloads/d4e5f6.jpg"
}
Download URLs are temporary. Save results to your own storage when the workflow needs durable retention.