Image perspective
Try it interactively →POST /api/image-perspectiveAuto-rectify a photo of a rectangle (document, whiteboard, painting): detects the four corners and warps the image so the rectangle is straight-on.
Inputs
| Name | Type | Default | Description |
|---|---|---|---|
| image* | file | — | Input image (PNG / JPEG / WebP). |
| points* | string | — | JSON-encoded array of 16 numbers (4 source/dest pairs in TL,TR,BR,BL order). |
| format | enum (png | jpeg | webp) | — | Output format. Defaults to the input's. |
Response
Modes: binary, base64-json. Cache: yes (24h TTL).
Code samples
Built from the tilt example.
# Download or substitute the example input:
# curl -O https://xtract.bot/examples/image-png-to-webp/sample.png
IMAGE=$(base64 -w0 < sample.png)
curl -X POST https://api.xtract.bot/api/image-perspective \
-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 '{
"points": "[0,0,20,0, 100,0,80,0, 100,100,100,100, 0,100,0,100]",
"image": "'"$IMAGE"'"
}'