xtract.bot

Image perspective warp

Try it interactively →
POST /api/image-perspective-warp

Warp an image with a 4-point perspective transform. Specify the four destination corners; the input is stretched into that quad.

Applies a 4-point perspective transform — supply the four `(x, y)` corners of the destination quad, and the input image is stretched to fill it. Useful for "stick this poster onto that wall in a photo" effects, faked-3D thumbnails, and rectifying photographs of rectangular objects taken at an angle. The output canvas is sized to the bounding box of the four destination corners; areas outside the quad are transparent.

Inputs

NameTypeDefaultDescription
image*fileSource image bytes.
corners*stringJSON: array of 4 `[x,y]` integer pairs in TL/TR/BR/BL order. Example: "[[10,20],[300,15],[310,210],[5,200]]".
outWidthnumber (0…8192)0Target width in pixels. 0 = derive from corner geometry (max of top/bottom edge lengths).
outHeightnumber (0…8192)0Target height in pixels. 0 = derive from corner geometry (max of left/right edge lengths).
formatenum (jpeg | png)"jpeg"Output encoding.
qualitynumber (1…100)90JPEG quality (ignored for PNG output).

Response

Modes: binary, base64-json. Cache: yes (24h TTL).