{
  "openapi": "3.1.1",
  "info": {
    "title": "Photo Tone Curves & Profile Processor API",
    "version": "1.0.0",
    "summary": "Apply levels, RGB curves and white balance, or reuse a Lumina photo profile.",
    "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://luminatoneprocessor.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Apply levels, RGB curves and white balance, or reuse a Lumina photo profile.",
        "description": "Develop a photo with black and white points, gamma, five-point master and RGB curves, and linear-light white-balance gains. Download a transparent PNG and reusable settings profile, or paste a profile saved from Lumina.\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- A supplied Lumina profile overrides all manual fields. Otherwise apply linear-light RGB gains, existing Develop exposure/contrast/saturation, encoded-sRGB levels and gamma, master curve, then channel curves. Five fixed inputs are interpolated with straight segments; outputs may be non-monotonic.\n- Gamma uses normalizedInput^(1/gamma). PNG retains the source alpha and omits source metadata. Profiles contain only adjustments and tone settings; camera PP3, RAW and ICC profiles are not supported.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "lumina_tone_processor",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LuminaToneProcessorInput"
              },
              "examples": {
                "example1": {
                  "summary": "Gentle contrast curve",
                  "value": {
                    "image": {
                      "filename": "sample.png",
                      "contentType": "image/png",
                      "contentBase64": "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAABlBMVEX/////AADrWueTAAAAEklEQVQI12NgIBb8/09dgjgAAPcnH+GApkH4AAAAAElFTkSuQmCC"
                    },
                    "master": "0,50,128,206,255"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LuminaToneProcessorResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "LuminaToneProcessorInput": {
        "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"
              }
            }
          },
          "profile": {
            "title": "Lumina profile JSON (optional; overrides all manual fields)",
            "type": "string",
            "maxLength": 64000,
            "default": ""
          },
          "black": {
            "title": "Input black",
            "type": "number",
            "minimum": 0,
            "maximum": 254,
            "default": 0
          },
          "white": {
            "title": "Input white",
            "type": "number",
            "minimum": 1,
            "maximum": 255,
            "default": 255
          },
          "gamma": {
            "title": "Midtone gamma",
            "type": "number",
            "minimum": 0.2,
            "maximum": 5,
            "default": 1
          },
          "exposure": {
            "title": "Exposure (EV)",
            "type": "number",
            "minimum": -3,
            "maximum": 3,
            "default": 0
          },
          "contrast": {
            "title": "Contrast",
            "type": "number",
            "minimum": -100,
            "maximum": 100,
            "default": 0
          },
          "saturation": {
            "title": "Saturation",
            "type": "number",
            "minimum": -100,
            "maximum": 100,
            "default": 0
          },
          "redGain": {
            "title": "Red linear-light gain",
            "type": "number",
            "minimum": 0.25,
            "maximum": 4,
            "default": 1
          },
          "greenGain": {
            "title": "Green linear-light gain",
            "type": "number",
            "minimum": 0.25,
            "maximum": 4,
            "default": 1
          },
          "blueGain": {
            "title": "Blue linear-light gain",
            "type": "number",
            "minimum": 0.25,
            "maximum": 4,
            "default": 1
          },
          "master": {
            "title": "Master curve outputs at 0,64,128,192,255",
            "type": "string",
            "maxLength": 40,
            "default": "0,64,128,192,255"
          },
          "red": {
            "title": "Red curve outputs at 0,64,128,192,255",
            "type": "string",
            "maxLength": 40,
            "default": "0,64,128,192,255"
          },
          "green": {
            "title": "Green curve outputs at 0,64,128,192,255",
            "type": "string",
            "maxLength": 40,
            "default": "0,64,128,192,255"
          },
          "blue": {
            "title": "Blue curve outputs at 0,64,128,192,255",
            "type": "string",
            "maxLength": 40,
            "default": "0,64,128,192,255"
          }
        },
        "required": [
          "image"
        ]
      },
      "LuminaToneProcessorResult": {
        "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",
              "artifact",
              "profile",
              "analysis"
            ],
            "properties": {
              "width": {
                "type": "integer"
              },
              "height": {
                "type": "integer"
              },
              "artifact": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "artifactId",
                  "filename",
                  "mime",
                  "bytes",
                  "sha256",
                  "path"
                ],
                "properties": {
                  "artifactId": {
                    "type": "string"
                  },
                  "filename": {
                    "type": "string"
                  },
                  "mime": {
                    "type": "string"
                  },
                  "bytes": {
                    "type": "integer"
                  },
                  "sha256": {
                    "type": "string"
                  },
                  "path": {
                    "type": "string",
                    "description": "Download path on the same site (valid for about 2 hours)."
                  }
                }
              },
              "profile": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "format",
                  "version",
                  "name",
                  "adjustments",
                  "development"
                ],
                "properties": {
                  "format": {
                    "const": "lumina-profile"
                  },
                  "version": {
                    "const": 1
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 80
                  },
                  "adjustments": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "exposure",
                      "contrast",
                      "highlights",
                      "shadows",
                      "temperature",
                      "tint",
                      "saturation",
                      "vibrance",
                      "fade",
                      "vignette",
                      "sharpen",
                      "denoise"
                    ],
                    "properties": {
                      "exposure": {
                        "type": "number",
                        "minimum": -3,
                        "maximum": 3
                      },
                      "contrast": {
                        "type": "number",
                        "minimum": -100,
                        "maximum": 100
                      },
                      "highlights": {
                        "type": "number",
                        "minimum": -100,
                        "maximum": 100
                      },
                      "shadows": {
                        "type": "number",
                        "minimum": -100,
                        "maximum": 100
                      },
                      "temperature": {
                        "type": "number",
                        "minimum": -100,
                        "maximum": 100
                      },
                      "tint": {
                        "type": "number",
                        "minimum": -100,
                        "maximum": 100
                      },
                      "saturation": {
                        "type": "number",
                        "minimum": -100,
                        "maximum": 100
                      },
                      "vibrance": {
                        "type": "number",
                        "minimum": -100,
                        "maximum": 100
                      },
                      "fade": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 100
                      },
                      "vignette": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 100
                      },
                      "sharpen": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 100
                      },
                      "denoise": {
                        "type": "number",
                        "minimum": 0,
                        "maximum": 100
                      }
                    }
                  },
                  "development": {
                    "type": "object",
                    "additionalProperties": false,
                    "required": [
                      "black",
                      "white",
                      "gamma",
                      "gains",
                      "curves"
                    ],
                    "properties": {
                      "black": {
                        "type": "integer",
                        "minimum": 0,
                        "maximum": 254
                      },
                      "white": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 255
                      },
                      "gamma": {
                        "type": "number",
                        "minimum": 0.2,
                        "maximum": 5
                      },
                      "gains": {
                        "type": "array",
                        "minItems": 3,
                        "maxItems": 3,
                        "items": {
                          "type": "number",
                          "minimum": 0.25,
                          "maximum": 4
                        }
                      },
                      "curves": {
                        "type": "object",
                        "additionalProperties": false,
                        "required": [
                          "master",
                          "red",
                          "green",
                          "blue"
                        ],
                        "properties": {
                          "master": {
                            "type": "array",
                            "minItems": 5,
                            "maxItems": 5,
                            "items": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 255
                            }
                          },
                          "red": {
                            "type": "array",
                            "minItems": 5,
                            "maxItems": 5,
                            "items": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 255
                            }
                          },
                          "green": {
                            "type": "array",
                            "minItems": 5,
                            "maxItems": 5,
                            "items": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 255
                            }
                          },
                          "blue": {
                            "type": "array",
                            "minItems": 5,
                            "maxItems": 5,
                            "items": {
                              "type": "integer",
                              "minimum": 0,
                              "maximum": 255
                            }
                          }
                        }
                      },
                      "hsl": {
                        "type": "object",
                        "additionalProperties": false,
                        "description": "Optional HSL color mixer. Bands: reds, oranges, yellows, greens, aquas, blues, purples, magentas. Hue ±100 = ±30°, saturation and luminance −100…100.",
                        "properties": {
                          "hue": {
                            "type": "array",
                            "minItems": 8,
                            "maxItems": 8,
                            "items": {
                              "type": "number",
                              "minimum": -100,
                              "maximum": 100
                            }
                          },
                          "saturation": {
                            "type": "array",
                            "minItems": 8,
                            "maxItems": 8,
                            "items": {
                              "type": "number",
                              "minimum": -100,
                              "maximum": 100
                            }
                          },
                          "luminance": {
                            "type": "array",
                            "minItems": 8,
                            "maxItems": 8,
                            "items": {
                              "type": "number",
                              "minimum": -100,
                              "maximum": 100
                            }
                          }
                        }
                      }
                    }
                  }
                }
              },
              "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"
                  }
                }
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}