xtract.bot
POST /api/png-to-avif

Convert a PNG to AVIF — typically 50% smaller than equivalent JPEG at the same quality. Configurable quality / speed tradeoff.

Re-encodes a PNG as AVIF. AVIF is the most efficient modern image format — typically 50% smaller than equivalent JPEG at the same perceptual quality. Quality is 1–100 (default 50). Higher quality preserves more detail but produces larger files. The encoder also exposes a `speed` tradeoff: higher numbers encode faster but produce larger output. Use AVIF when you control both ends (your CDN serves it, your browsers decode it). For broader compatibility, WebP and JPEG remain better choices.

Inputs

NameTypeDefaultDescription
image*fileInput PNG bytes.
qualitynumber (0…100)50AVIF visual quality 0–100 (50 ≈ JPEG q80). Ignored when lossless=true.
effortnumber (0…10)4Encoder effort 0–10. Higher = smaller file, more CPU.
losslessbooleanfalseWhen true, encode losslessly. `quality` is ignored.

Response

Modes: binary, base64-json. Cache: yes (24h TTL).

Code samples

Built from the default example.

# Download or substitute the example input:
#   curl -O https://xtract.bot/examples/image-png-to-webp/sample.png
IMAGE=$(base64 -w0 < sample.png)

curl -X POST https://api.xtract.bot/api/png-to-avif \
  -H "Content-Type: application/json" \
  -H "Accept: application/octet-stream" \
  -H "X-Account-Id: $XTRACT_ACCOUNT_ID" \
  -H "X-Api-Key: $XTRACT_API_KEY" \
  -d '{
  "image": "'"$IMAGE"'"
}'