{
  "openapi": "3.1.1",
  "info": {
    "title": "Photo Histogram & Clipping Analyzer API",
    "version": "1.0.0",
    "summary": "Inspect RGB histograms, clipped channels and tonal percentiles in a photo.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://luminahistogramanalyzer.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Inspect RGB histograms, clipped channels and tonal percentiles in a photo.",
        "description": "Upload a photo to measure luminance and RGB distributions, shadow and highlight clipping, and tonal percentiles. Download the full 256-bin analysis and get percentile-based black and white starting points.\n\nMethodology:\n- Auto-oriented, display-referred 8-bit sRGB analysis. Fully transparent pixels are excluded; other pixels count equally.\n- Luma is rounded 0.2126 R + 0.7152 G + 0.0722 B. Clipping counts any channel at or below 2, or at or above 253. This does not measure sensor exposure or recover clipped RAW data.\n- Report 1st, 50th and 99th luminance percentiles using nearest-rank selection. Suggested levels discard 0.5% from each luminance tail; flat or empty images retain 0–255. Values are suggestions, not an exposure judgment.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "lumina_histogram_analyzer",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LuminaHistogramAnalyzerInput"
              },
              "examples": {
                "example1": {
                  "summary": "Inspect a red image",
                  "value": {
                    "image": {
                      "filename": "sample.png",
                      "contentType": "image/png",
                      "contentBase64": "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAABlBMVEX/////AADrWueTAAAAEklEQVQI12NgIBb8/09dgjgAAPcnH+GApkH4AAAAAElFTkSuQmCC"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LuminaHistogramAnalyzerResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "LuminaHistogramAnalyzerInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "image": {
            "title": "Image (PNG, JPEG or WebP; up to 8 MB and 16 MP)",
            "type": "object",
            "description": "Upload as {filename, contentType?, contentBase64}. Max 7813 KiB. Accepts .png,.jpg,.jpeg,.webp.",
            "additionalProperties": false,
            "required": [
              "filename",
              "contentBase64"
            ],
            "properties": {
              "filename": {
                "type": "string"
              },
              "contentType": {
                "type": "string"
              },
              "contentBase64": {
                "type": "string"
              }
            }
          }
        },
        "required": [
          "image"
        ]
      },
      "LuminaHistogramAnalyzerResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "width",
              "height",
              "analysis",
              "suggestedLevels"
            ],
            "properties": {
              "width": {
                "type": "integer"
              },
              "height": {
                "type": "integer"
              },
              "analysis": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "bins",
                  "visible",
                  "transparent",
                  "mean",
                  "shadow",
                  "highlight",
                  "shadowPercent",
                  "highlightPercent",
                  "p01",
                  "median",
                  "p99"
                ],
                "properties": {
                  "bins": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "luminance",
                      "red",
                      "green",
                      "blue"
                    ],
                    "properties": {
                      "luminance": {
                        "type": "array",
                        "minItems": 256,
                        "maxItems": 256,
                        "items": {
                          "type": "integer"
                        }
                      },
                      "red": {
                        "type": "array",
                        "minItems": 256,
                        "maxItems": 256,
                        "items": {
                          "type": "integer"
                        }
                      },
                      "green": {
                        "type": "array",
                        "minItems": 256,
                        "maxItems": 256,
                        "items": {
                          "type": "integer"
                        }
                      },
                      "blue": {
                        "type": "array",
                        "minItems": 256,
                        "maxItems": 256,
                        "items": {
                          "type": "integer"
                        }
                      }
                    }
                  },
                  "visible": {
                    "type": "integer"
                  },
                  "transparent": {
                    "type": "integer"
                  },
                  "mean": {
                    "type": "number"
                  },
                  "shadow": {
                    "type": "integer"
                  },
                  "highlight": {
                    "type": "integer"
                  },
                  "shadowPercent": {
                    "type": "number"
                  },
                  "highlightPercent": {
                    "type": "number"
                  },
                  "p01": {
                    "type": "integer"
                  },
                  "median": {
                    "type": "integer"
                  },
                  "p99": {
                    "type": "integer"
                  }
                }
              },
              "suggestedLevels": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "black",
                  "white"
                ],
                "properties": {
                  "black": {
                    "type": "integer"
                  },
                  "white": {
                    "type": "integer"
                  }
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}