crop_image
Crop an image
Extract a rectangular region from an image, in one of three mutually exclusive modes. Manual: give the top-left corner (x, y) and dimensions (width, height) in pixels. Smart crop: give 'gravity' (attention, entropy, centre) plus width and height; the window is picked automatically, clamped to the source if the target is larger. Trim: set 'trim: true' (optional 'threshold') to remove a uniform background border via content detection; the applied rect is reported in X-Pictomancer-Trim-* headers. Optional enhancement modifiers: denoise (1-3), equalize, sharpen (applied denoise -> equalize -> op -> sharpen).
Responses:
200: Processed image binary (Success Response) Content-Type: application/json Content-Type: image/jpeg
Example Response:
"string"Content-Type: image/png
Example Response:
"string"Content-Type: image/webp
Example Response:
"string"Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| x | No | Left edge of the crop rectangle in pixels. Manual mode only. | |
| y | No | Top edge of the crop rectangle in pixels. Manual mode only. | |
| trim | No | Trim mode: removes a uniform background border via content detection. Mutually exclusive with x/y/width/height/gravity. | |
| width | No | Width of the crop rectangle in pixels. Required in manual and gravity modes. | |
| format | No | Output format: jpeg, png, webp, tiff, gif, or avif. If omitted, the original format is preserved. | |
| height | No | Height of the crop rectangle in pixels. Required in manual and gravity modes. | |
| source | Yes | Image source: a public URL (https://...) or a base64-encoded string (optionally as a data URI like data:image/png;base64,...). | |
| autorot | No | Apply EXIF orientation before cropping. Opt-in; default false, which preserves current byte-for-byte behavior. | |
| denoise | No | Median denoise before cropping: radius 1-3 (window 3x3 to 7x7). Opt-in; no surcharge. | |
| gravity | No | Smart-crop mode: picks the window automatically. One of ('attention', 'entropy', 'centre'). Requires width and height; mutually exclusive with x/y and trim. A target larger than the source clamps to the source size. | |
| sharpen | No | Unsharp-mask sharpen after cropping (libvips defaults). Opt-in. | |
| delivery | No | ||
| equalize | No | Auto-contrast (histogram equalisation of the value channel; hue and saturation preserved) before cropping. Opt-in. | |
| threshold | No | Trim sensitivity (must be positive; default 10.0). Only valid together with trim: true. |