Pular para o conteúdo
POST AI agent ready /v1/image/convert

Image Convert API - Check Supported Format Conversions

Accepts a url or base64 image and a from/to format pair (jpeg, jpg, png, gif, webp, avif, bmp, tiff, svg). Returns whether the conversion is supported by common tooling plus a note explaining the recommended pipeline. Native pixel transcoding is not performed in edge Workers; this endpoint guides client-side or server-side implementation.

Parameters

string

Image URL. Provide url or base64.

string

Base64-encoded image. Provide url or base64.

stringrequired

Source format.

stringrequired

Target format.

Code examples

curl -X POST https://api.botoi.com/v1/image/convert \
  -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/avatar.png","from":"png","to":"webp"}'

When to use this API

Validate conversion feasibility before starting a job

In an image-pipeline tool, query this endpoint to check whether a requested conversion (e.g., avif→png) is realistic before queueing the work. Fails fast on unsupported pairs.

Route conversions to the right worker

Simple conversions (jpeg↔png) run in browser Canvas. Complex ones (heic→jpeg, avif→webp) need a dedicated Sharp worker. Use the supported flag to branch.

Document conversion options in a UI

In an image-upload form, fetch the supported flag for each format pair and gray out unsupported options before the user picks.

Frequently asked questions

Why doesn't this actually convert the image?
Native image transcoding requires libraries (Sharp, libvips, ImageMagick) that don't run in Cloudflare Workers without WASM support. This endpoint gives conversion feasibility and recommended pipelines; run the actual conversion on a regular server or in a browser Canvas.
Which conversions are marked supported?
Conversions browsers handle natively via Canvas API: jpeg↔png, png↔webp, jpeg↔webp, gif→png, bmp→png/jpeg. Others return supported:false with guidance to use a server-side library.
Is base64 input validated?
The size is estimated from the string length; format integrity is not verified. For strict validation use /v1/image/metadata first.
What about heic, avif, or tiff?
Listed as supported formats but few browsers handle them natively. The note field nudges toward server-side Sharp for these.
Will this feature add real conversion later?
The roadmap includes a Sharp-backed conversion worker for the common pairs. For now, this endpoint is the discovery layer that tells your pipeline what's worth attempting.

Get your API key

Free tier includes 5 requests per minute with no credit card required. Upgrade for higher limits.