Image Enhancement
Enhances an image: tone, color grade, black-and-white conversion, despeckle, and re-encode.#
/lmkit/v1/image-enhanceOne pass over the pixels of an image, the counterpart of image-normalization (which owns geometry). The stages apply in a fixed order - 'invert', 'tone' (exposure, brightness, contrast, highlights, shadows, saturation, sharpness over [-1, 1]), one 'look' (negative, sepia, mono, vivid, warm, cool, fade), 'binarize' ('otsu' for one global threshold, 'smart' for the adaptive OCR-grade conversion), 'despeckle' (removes isolated noise from the black-and-white result while keeping dots and diacritics), then 'flatten_background' (composites a transparent image over a color). 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) and 'tiff' keep a black-and-white result at one bit per pixel, 'webp' and 'jpeg' are lossy ('output_quality'). 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'. | |
page_index | object (int32) | Zero-based page of a multi-page image (a TIFF scan) to process. Default: 0. An index past the last page is refused with 400. |
invert | boolean | Inverts every color channel first (a negative scan, white-on-black text). Default: off. |
tone | Tonal adjustments applied to the image. Omit for none. | |
look | One deterministic color grade applied after the tone: 'none' (default), 'negative', 'sepia', 'mono', 'vivid', 'warm', 'cool', or 'fade'. | |
binarize | Black-and-white conversion: 'none' (default), 'otsu' (one global threshold), or 'smart' (adaptive, OCR-grade). The result is one bit per pixel; 'png' and 'tiff' keep it that way. | |
despeckle | boolean | Removes isolated speckle noise from the black-and-white result while keeping dots, diacritics and punctuation near text. Requires 'binarize'. Default: off. |
max_speckle_area | object (int32) | Despeckle: largest connected blob, in pixels, still treated as noise. 0 (default) derives it from the image resolution (about 25 pixels at 300 DPI). |
flatten_background | string | Composites a transparent image over this '#RRGGBB' color, removing the alpha channel. Omit to keep transparency (it has no effect on an opaque image). |
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 and keeps a black-and-white result at one bit per pixel. | |
output_quality | object (int32) | Quality (1-100) for the lossy encodings ('webp', 'jpeg'); ignored for 'png' and 'tiff'. 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-enhance" \
-H "Authorization: Bearer $LMKIT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": "",
"input_format": "Base64EncodedFile",
"page_index": 0,
"invert": false,
"tone": {
"exposure": 0,
"brightness": 0,
"contrast": 0,
"highlights": 0
}
}'