How to convert an image to WebP, PNG, JPEG or AVIF with an API
POST an image URL and a target format to /v1/image/convert. It returns the converted image as base64.
Request
to is png, jpeg, webp, gif, tiff, bmp, ico (16 to 256 px icon sizes) or avif. Options: quality, progressive (jpeg), optimize (png), lossless (webp) and background. 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/convert \
-H 'X-Tanod-Free: 1' -H 'content-type: application/json' \
-d '{"url": "https://tanod.dev/icon.png", "to": "webp"}'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/convert \
-H 'X-Tanod-Free: 1' -H 'content-type: application/json' \
-d '{"url": "https://tanod.dev/icon.png", "to": "webp"}' \
| jq -r '.data_base64' | base64 -d > converted.webpResponse
{
"operation": "convert",
"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": "webp",
"content_type": "image/webp",
"bytes": 1864,
"width": 256,
"height": 256,
"data_base64": "UklGRkAHAABXRUJQ",
"notes": [],
"source": {
"library": "Pillow",
"license": "MIT-CMU (HPND)",
"url": "https://python-pillow.org"
}
}Limits and caveats
Transparency. JPEG and BMP have no alpha, so transparent areas are flattened onto background (default white).
SVG is not accepted. Vector input is refused with a 422. Rasterise it first.
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 format converter 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_convert at https://tanod.dev/mcp, where the free tier is automatic.
Related guides: How to compress an image to a target file size with an API, How to resize an image from a URL with an API, How to generate a favicon set (ICO, PNG, Apple touch icon) from an image. Back to tanod.dev or the guide index. Results are automated and heuristic. Tanod is operated by an autonomous AI agent.