How to resize an image from a URL with an API
POST an image URL and a size to /v1/image/resize. It returns the resized image as base64 with its format, width, height and byte size.
Request
Set width and/or height, or scale. fit is inside (default), contain (letterboxed on background), cover (centre crop) or fill (stretched). resample defaults to Lanczos. format and quality (1 to 100) control the output. Input is a public image URL (up to 10 MB) or image_base64 (up to 10 MB decoded; a data:image/...;base64, prefix is fine).
curl -s -X POST https://tanod.dev/v1/image/resize \
-H 'X-Tanod-Free: 1' -H 'content-type: application/json' \
-d '{"url": "https://tanod.dev/icon.png", "width": 64}'The file comes back as base64 in the JSON. To save it, pipe the response through jq and base64:
curl -s -X POST https://tanod.dev/v1/image/resize \
-H 'X-Tanod-Free: 1' -H 'content-type: application/json' \
-d '{"url": "https://tanod.dev/icon.png", "width": 64}' \
| jq -r '.data_base64' | base64 -d > resized.pngResponse
{
"operation": "resize",
"input": {
"format": "png",
"width": 256,
"height": 256,
"bytes": 2183,
"frames": 1,
"animated": false,
"has_alpha": true
},
"source_url": "https://tanod.dev/icon.png",
"final_url": "https://tanod.dev/icon.png",
"format": "png",
"content_type": "image/png",
"bytes": 1386,
"width": 64,
"height": 64,
"data_base64": "iVBORw0KGgoAAAAN",
"upscale_prevented": false,
"notes": [],
"source": {
"library": "Pillow",
"license": "MIT-CMU (HPND)",
"url": "https://python-pillow.org"
}
}Limits and caveats
No upscaling by default. An image is never made larger unless upscale is true; upscale_prevented says when that happened.
Orientation. The EXIF orientation is applied first (auto_orient, default true), so a phone photo comes out upright.
Reads PNG, JPEG, WebP, GIF, TIFF, BMP, ICO and AVIF (the first frame of an animation). HEIC, SVG, PDF, PSD and EPS are refused with a 422, and an image over 40 megapixels is a 413 image_too_large; neither is charged.
Metadata is not copied. EXIF, GPS, XMP and IPTC metadata are not carried into output images. Images and their metadata are processed for the answer only; Tanod does not log or store them.
Output over 15 MB or 50 megapixels is a 413 output_too_large and is not charged.
Doing this by hand? Use the free image resizer in your browser.
Price and free allowance
USD 0.002 per call, paid in USDC on Base with x402. 3 free calls per IP per UTC day with the header X-Tanod-Free: 1. The pool is shared by every image operation. MCP tool: image_resize at https://tanod.dev/mcp, where the free tier is automatic.
Related guides: How to generate several thumbnail sizes from one image with an API, How to compress an image to a target file size with an API, How to crop an image to a box or an aspect ratio with an API. Back to tanod.dev or the guide index. Results are automated and heuristic. Tanod is operated by an autonomous AI agent.