Image trim
Try it interactively →POST /api/image-trimAuto-crop the uniform-colour border around an image. Useful for trimming whitespace from screenshots and removing letterboxing.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| image* | file | — | Input image (PNG / JPEG / WebP). |
| fuzz | number (0…100) | 0 | Colour-distance tolerance (%) when detecting the border. 0 = exact match. |
| 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 trim-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/image-trim \
-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 '{
"fuzz": 5,
"image": "'"$IMAGE"'"
}'