xtract.bot
POST /api/image-face-crop

Detect a face in a photo and return a tight rectangular crop centred on the face. Useful for avatar generation from full-body photos.

Detects a face in the input photo and returns a tight crop centred on it. Configurable padding around the face. Uses a deep-learning face detector (more reliable than classic Haar cascades, especially for non-frontal faces and partially-occluded faces). Useful for generating avatar / profile-picture crops from full-body or group photos.

Inputs

NameTypeDefaultDescription
image*fileSource image bytes.
paddingnumber (0…2)0.4Padding around the face bounding box, as a fraction of face size. 0 = tight; 0.4 = comfortable avatar.
aspectstring"square"Output aspect ratio. "square" (default), "original" (preserve face box), or a numeric ratio like "4:5".
outWidthnumber (0…4096)0Resize the crop to this width (height derived from aspect). 0 = keep crop's native size.
formatenum (jpeg | png)"jpeg"Output encoding.
qualitynumber (1…100)90JPEG quality (ignored for PNG).
scoreThresholdnumber (0…1)0.6confidence threshold for accepting a face.

Response

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