xtract.bot
POST /api/image-trim

Auto-crop the uniform-colour border around an image. Useful for trimming whitespace from screenshots and removing letterboxing.

Detects a uniform-colour border around an image and crops it away. Useful for: - Trimming whitespace around screenshots. - Removing letterboxing from videos / images. - Cleaning up scanned documents that have margin noise. The `tolerance` option (0–1, default 0.05) controls how close to uniform the border must be. Higher values trim more aggressively.

Inputs

NameTypeDefaultDescription
image*fileInput image (PNG / JPEG / WebP).
fuzznumber (0…100)0Colour-distance tolerance (%) when detecting the border. 0 = exact match.
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 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"'"
}'