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

Convert JPEG to AVIF — typically 30–50% smaller at the same perceptual quality. Configurable quality / encoder effort tradeoff.

Re-encodes a JPEG as AVIF. AVIF is the most efficient modern image format — typically 30–50% smaller than the source JPEG at visually equivalent quality. Quality is 1–100 (default 50). Higher quality preserves more detail but produces larger files. The encoder also exposes an `effort` tradeoff: higher numbers encode slower but produce smaller output. Note that the source JPEG was already lossy — encoding to AVIF won't *recover* detail, only shrink the file at similar visual quality. 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 JPEG 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 from the decoded JPEG pixels. `quality` is ignored. The source JPEG was already lossy upstream, so this preserves the decode but doesn't recover the original capture.

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-resize-jpeg/sample.jpg
IMAGE=$(base64 -w0 < sample.jpg)

curl -X POST https://api.xtract.bot/api/jpeg-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"'"
}'