gimp_get_histogram
Computes per-channel histogram and statistics (mean, median, percentiles) from a GIMP image render to check exposure and clipping before export.
Instructions
Headless GIMP: statistics for several channels from ONE render: mean, median, 1st/5th/95th/99th percentiles, and a 256-bin histogram per channel (bins[v] = pixel count at value v, 0-255). luminance uses babl's D50 perceptual weights. Default is fast (~0.3s, the 1024px proxy render) — good for iterating, but small clipped highlights can be under-counted; pass exact: true (~4s on 24MP) as the final clipping check before gimp_export.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"image": "<image>"
},
"name": "gimp_get_histogram"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| mask | No | The name of a selection channel: measure only the pixels it selects at 50% or more (a hard cut, no partial credit for soft edges), e.g. the mean lightness or color of a selected object. Combines with region and exact; pixels in the result is the number of pixels counted. | |
| exact | No | false (default): computed on the 1024px proxy render (~0.3s) — good for iterating, but small clipped highlights can be under-counted. true: full-resolution composite (~4s on 24MP) — the trustworthy final clipping check before export. On a very large document true can take much longer; a call that runs past its time limit keeps running and the next call waits for it; ask again then for the reading. | |
| image | Yes | Image id, as returned by gimp_open_document. | |
| region | No | A rectangle in document pixels: {x, y, width, height}. Must lie entirely within the image — a region partly or fully outside it is refused rather than silently clamped. Computed on the proxy when it maps to a big-enough proxy area, else auto-falls back to a full-resolution crop; exact:true always forces the full-resolution crop. | |
| channels | No | Default: all four (luminance, red, green, blue) in ONE render. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| exact | No | ||
| width | No | ||
| height | No | ||
| pixels | No | ||
| channels | No | Keyed by channel name (luminance, red, green, blue). | |
| unmirrored_filters | No | Names of live filters GIMP refused to re-attach on this proxy render — absent from these stats entirely. Present whenever histogram actually used the (mirrored) preview proxy: the default whole-image path, OR a `region` large enough to be sampled from the proxy rather than falling back to a full-resolution crop. Absent when exact: true, or when a region is too small and falls back to that full-resolution crop — neither path mirrors filters at all. |