LM-Kit OneDocs2026.9.7lm-kit.comEULA
Image Utilities

Image Normalization

Normalizes an image: rotate, flip, deskew, crop, auto-crop uniform borders, resize, and re-encode.#

POST/lmkit/v1/image-normalization

One pass that prepares an image for vision, OCR, or archival pipelines. The geometry stages apply in a fixed order - 'rotate' (90/180/270), 'flip' (horizontal/vertical), 'deskew' (straightens a tilted scan and reports 'deskew_angle'), 'crop' (an explicit pixel region), then 'auto_crop' (trims uniform borders such as scan margins or letterboxing, tuned by 'crop_margin' and 'crop_tolerance'), then ONE resize: 'long_side' scales proportionally so the longer side measures exactly that many pixels, 'width'+'height' force exact dimensions, and 'fit_box' scales to fit inside a box and pads the rest with a color. 'output_dpi' writes a resolution into the file for consumers that read it. Use 'page_index' to pick a page of a multi-page TIFF. Every stage is optional; a request with none of them is a plain format conversion. The result is returned base64-encoded in 'output_format' - 'png' (default), 'webp' and 'tiff' keep any alpha channel or bit depth, '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 ·

PropertyTypeDescription
inputrequiredstring

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

page_indexobject (int32)

Zero-based page of a multi-page image (a TIFF scan) to process. Default: 0. A single-page image accepts 0 only; an index past the last page is refused with 400.

rotateobject (int32)

Clockwise rotation in degrees: 0 (default, none), 90, 180, or 270.

flip

Mirror applied after the rotation: 'none' (default), 'horizontal', or 'vertical'.

deskewboolean

Straightens a tilted scan: measures the skew of the text lines and rotates by the opposite angle. The measured angle is reported in 'deskew_angle'; a tilt below 'deskew_min_angle' is left alone. Default: off.

deskew_max_angleobject (float)

Deskew: largest tilt searched, in degrees (2-45). Default: 15.

deskew_min_angleobject (float)

Deskew: smallest tilt worth correcting, in degrees; below it the image is considered straight. Default: 0.5.

crop

Explicit region to keep, in pixels of the image as it stands after rotate, flip and deskew. A region reaching outside the image is refused with 400. Omit for no explicit crop.

auto_cropboolean

Removes uniform borders (scan margins, letterboxing) by trimming every edge whose pixels match the corner color. Default: off.

crop_marginobject (int32)

Auto-crop: pixels of border kept around the detected content. Default: 0.

crop_toleranceobject (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_sideobject (int32)

Aspect-preserving resize: scales the image so its longer side measures exactly this many pixels (up or down). Mutually exclusive with 'width'/'height' and 'fit_box'. Omit for no proportional resize.

widthobject (int32)

Exact resize: target width in pixels. Requires 'height'; mutually exclusive with 'long_side' and 'fit_box'.

heightobject (int32)

Exact resize: target height in pixels. Requires 'width'; mutually exclusive with 'long_side' and 'fit_box'.

fit_box

Contain-fit resize: scales proportionally to fit inside the box and pads the rest with the box's background color, so the output measures exactly the box. Mutually exclusive with the other resizes.

output_dpiobject (float)

Resolution written into the output file, in dots per inch, for consumers that read it (OCR, PDF assembly). Pixels are not resampled. Omit to keep the source resolution.

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; 'tiff' is lossless.

output_qualityobject (int32)

Quality (1-100) for the lossy encodings ('webp', 'jpeg'); ignored for 'png' and 'tiff'. Default: 80.

Responses

StatusTypeDescription
200

OK

202

Accepted

400

Bad Request

500application/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",
  "page_index": 0,
  "rotate": 0,
  "flip": "none"
}'