xtract.bot
POST /api/image-rotate

Rotate an image by any angle (in degrees). Configurable background fill for the corners exposed by non-90° rotations.

Rotates the image by `angle` degrees clockwise. For 90 / 180 / 270 the canvas dimensions adjust to fit the result snugly. For arbitrary angles, the canvas grows to contain the rotated image and the new corners are filled with the configured `background` colour (default transparent for PNG, white for JPEG).

Inputs

NameTypeDefaultDescription
image*fileInput image (PNG / JPEG / WebP).
degrees*number (-360…360)Clockwise rotation angle in degrees.
bgColorstring"white"Fill colour for corner triangles on non-right-angle rotations (CSS-style names or #rrggbb).
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 rotate-90 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-rotate \
  -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 '{
  "degrees": 90,
  "image": "'"$IMAGE"'"
}'