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

Convert a PNG to JPEG. Configurable quality (1–100). Transparency is flattened against a configurable background colour.

Reads a PNG and returns the same picture as a JPEG. Quality is configurable (default 80) — `1` is tiny and ugly, `100` is near-lossless and large. PNG transparency must be flattened because JPEG does not support alpha. The default is to composite over white; pass `background` (a hex colour) to use a different fill.

Inputs

NameTypeDefaultDescription
image*filePNG bytes.
qualitynumber (1…100)80JPEG quality 1–100. Default 80.

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-jpeg \
  -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": 80,
  "image": "'"$IMAGE"'"
}'