xtract.bot
POST /api/image-resize

Resize an image to a target width and height. Pass only one dimension to preserve aspect ratio. High-quality Lanczos resampling.

Resizes the input to the requested `width` × `height` in pixels. Pass `width=0` (or omit) to derive width from height, and vice versa, preserving the source aspect ratio. At least one of `width` and `height` must be > 0. Resampling uses Lanczos — high-quality. Output format defaults to the input's format; override with `format` to re-encode at a different format in the same call.

Inputs

NameTypeDefaultDescription
image*fileInput image (PNG / JPEG / WebP).
widthnumber (0…16384)0Target width in pixels. 0 (default) means derive from height to preserve aspect ratio.
heightnumber (0…16384)0Target height in pixels. 0 (default) means derive from width to preserve aspect ratio.
formatenum (png | jpeg | webp)Output format. Defaults to the input's format.

Response

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

Code samples

Built from the resize-jpeg-half 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/image-resize \
  -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 '{
  "width": 16,
  "height": 0,
  "image": "'"$IMAGE"'"
}'