ohmywrap
Get an API key

§ Transform

Crop Image API

Exactly one of three modes per request: an explicit rectangle, a smart crop to a size, or a trim that removes a uniform border. Mixing them is a 422 — a request carrying both a rectangle and a strategy has not decided what it wants.

Endpoint
POST /image/crop
Inputs
Exactly 1 image
Returns
The encoded image
Limits
20 MB per file, 50 M pixels in, 50 M pixels out.
Price
$0.001

§ 01 The request

One POST, and the file comes back.

POST /image/crop
curl -sS --fail-with-body \
  -o trimmed.png \
  -H "Authorization: Bearer $OHMYWRAP_KEY" \
  -F "file=@scan.png" \
  -F 'options={"trim":{"threshold":15,"background":"#ffffff"}}' \
  https://api.ohmywrap.com/image/crop

Options

Options accepted inside the options JSON object
OptionTypeDefaultWhat it does
left, top, width, heightintRectangle mode. All four, and inside the image.
strategystringStrategy mode, with width and height: `attention`, `entropy`, `centre`.
trimobjectTrim mode: {"threshold": 10, "background": "#ffffff"}.
autoOrientbooltrueApply the EXIF orientation before transforming. Turning it off costs the shrink-on-load fast path.
animatedboolfalseProcess every frame of an animated GIF or WebP instead of flattening to the first.
outputobjectThe shared encode block: format, quality, lossless, effort, progressive, keepMetadata.

Worth knowing

A rectangle that falls outside the image is 422 invalid_crop, and the error quotes the rectangle and the image size.

Your first /image/crop call takes one line of curl.

Ten thousand calls cost ten dollars, the pack never expires, and nothing you send is kept.

10,000 calls for $10. No subscription, no expiry.