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).

post/v1/crop

Request

  • Base URL: https://api.pictomancer.ai (the document declares no server; this is the origin it was published from)
  • URL: https://api.pictomancer.ai/v1/crop
  • Auth: none declared

Request body

sourcestring required

Image source: a public URL (https://...) or a base64-encoded string (optionally as a data URI like data:image/png;base64,...).

xinteger nullable

Left edge of the crop rectangle in pixels. Manual mode only.

yinteger nullable

Top edge of the crop rectangle in pixels. Manual mode only.

widthinteger nullable

Width of the crop rectangle in pixels. Required in manual and gravity modes.

heightinteger nullable

Height of the crop rectangle in pixels. Required in manual and gravity modes.

gravitystring nullable

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.

trimboolean nullable

Trim mode: removes a uniform background border via content detection. Mutually exclusive with x/y/width/height/gravity.

thresholdnumber nullable

Trim sensitivity (must be positive; default 10.0). Only valid together with trim: true.

autorotboolean nullable

Apply EXIF orientation before cropping. Opt-in; default false, which preserves current byte-for-byte behavior.

denoiseinteger nullable

Median denoise before cropping: radius 1-3 (window 3x3 to 7x7). Opt-in; no surcharge.

equalizeboolean nullable

Auto-contrast (histogram equalisation of the value channel; hue and saturation preserved) before cropping. Opt-in.

sharpenboolean nullable

Unsharp-mask sharpen after cropping (libvips defaults). Opt-in.

formatstring nullable

Output format: jpeg, png, webp, tiff, gif, or avif. If omitted, the original format is preserved.

Response

Processed image binary

unknown required

Changes

No recorded changes to this operation across all 1 revision of this API.