Image Normalization
Normalizes an image: rotate, auto-crop uniform borders, resize, and re-encode.#
/lmkit/v1/image-normalizationOne pass that prepares an image for vision, OCR, or archival pipelines. The operations apply in a fixed order - 'rotate' (90/180/270), then 'auto_crop' (trims uniform borders such as scan margins or letterboxing, tuned by 'crop_margin' and 'crop_tolerance'), then a resize: 'long_side' scales proportionally so the longer side measures exactly that many pixels, while 'width'+'height' force exact dimensions. Every operation is optional; a request with none of them is a plain format conversion. The result is returned base64-encoded in 'output_format' - 'png' (default) and 'webp' keep any alpha channel, 'jpeg' is flattened over opaque white ('output_quality' drives the lossy encoders). No AI model is involved: the pass is pure image processing and runs on any server. If processing exceeds the configured timeout, returns 202 Accepted with a job_id. Poll GET /lmkit/v1/jobs/ for status and results.
Request body
application/json ·
| Property | Type | Description |
|---|---|---|
inputrequired | string | The input image. When input_format is 'Base64EncodedFile', provide a base64-encoded image payload. When 'FileIdentifier', provide the file ID previously returned by the lmkit/v1/files/upload endpoint. |
input_format | How the input is provided. Accepted values: 'Base64EncodedFile' or 'FileIdentifier'. Defaults to 'Base64EncodedFile'. | |
rotate | object (int32) | Clockwise rotation in degrees: 0 (default, none), 90, 180, or 270. |
auto_crop | boolean | Removes uniform borders (scan margins, letterboxing) by trimming every edge whose pixels match the corner color. Default: off. |
crop_margin | object (int32) | Auto-crop: pixels of border kept around the detected content. Default: 0. |
crop_tolerance | object (int32) | Auto-crop: per-channel distance (0-255) a border pixel may sit from the corner color and still count as border. 0 (default) trims exact matches only; raise it for noisy scans. |
long_side | object (int32) | Aspect-preserving resize: scales the image so its longer side measures exactly this many pixels (up or down). Mutually exclusive with 'width'/'height'. Omit for no proportional resize. |
width | object (int32) | Exact resize: target width in pixels. Requires 'height'; mutually exclusive with 'long_side'. |
height | object (int32) | Exact resize: target height in pixels. Requires 'width'; mutually exclusive with 'long_side'. |
output_format | Encoding of the returned image. 'png' (default, lossless) and 'webp' (lossy) keep any alpha channel; 'jpeg' cannot hold transparency and is flattened over opaque white. | |
output_quality | object (int32) | Quality (1-100) for the lossy encodings ('webp', 'jpeg'); ignored for 'png'. Default: 80. |
Responses
| Status | Type | Description |
|---|---|---|
| 200 | OK | |
| 202 | Accepted | |
| 400 | Bad Request | |
| 500 | application/json | Internal Server Error |
curl -X POST "$LMKIT_ONE_URL/lmkit/v1/image-normalization" \
-H "Authorization: Bearer $LMKIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "",
"input_format": "Base64EncodedFile",
"rotate": 0,
"auto_crop": false,
"crop_margin": 0
}'