xtract.bot
POST /api/image-png-to-webp

Convert a PNG to WebP. Configurable quality, optional lossless mode (perfect round-trip with smaller files than PNG).

Re-encodes a PNG as WebP. With `lossless: true` (default), the result is pixel-for-pixel equivalent to the input but typically ~30% smaller than the equivalent PNG. For lossy WebP, set `lossless: false` and supply a `quality` (1–100). Lossy WebP produces dramatically smaller files than PNG for photographic content.

Inputs

NameTypeDefaultDescription
image*filePNG image bytes.
qualitynumber (1…100)75WebP quality (1–100). Ignored when lossless=true.
losslessbooleanfalseIf true, encode losslessly (preserves pixels exactly).

Response

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

Code samples

Built from the tile 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/image-png-to-webp \
  -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 '{
  "quality": 75,
  "lossless": false,
  "image": "'"$IMAGE"'"
}'