Image resize
Try it interactively →POST /api/image-resizeResize an image to a target width and height. Pass only one dimension to preserve aspect ratio. High-quality Lanczos resampling.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| image* | file | — | Input image (PNG / JPEG / WebP). |
| width | number (0…16384) | 0 | Target width in pixels. 0 (default) means derive from height to preserve aspect ratio. |
| height | number (0…16384) | 0 | Target height in pixels. 0 (default) means derive from width to preserve aspect ratio. |
| format | enum (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"'"
}'