{
  "openapi": "3.1.1",
  "info": {
    "title": "Lens Distortion, Color Fringe \u0026 Vignetting Correction API",
    "version": "1.0.0",
    "summary": "Straighten barrel or pincushion distortion, shrink red/blue fringes and brighten dark corners.",
    "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://luminalenscorrect.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Straighten barrel or pincushion distortion, shrink red/blue fringes and brighten dark corners.",
        "description": "Upload a photo and correct barrel or pincushion lens distortion with a two-term radial model, align the red and blue channels to reduce lateral color fringes, and brighten or darken the corners in linear light. Automatic scaling fills the frame without empty corners. Download a PNG plus the settings as JSON for the Lumina photo editor, where the same correction stays editable.\n\nMethodology:\n- Auto-oriented, display-referred 8-bit sRGB. The radius is measured from the image centre in half-diagonal units (1 in the corners). Sampling is bilinear on premultiplied alpha; the output keeps the input size.\n- A manual, generic radial model: no lens database, camera profile or EXIF lens data is used, and fisheye projections are not supported.\n- Each output pixel centre is divided by the zoom, then sampled at radius r × (1 + k1·r² + k2·r⁴) (Lensfun 5th-order polynomial model). Red and blue are sampled at that position scaled by 1 + 0.00002 × value (linear TCA model) and clamped to the photo edge.\n- Corner brightness multiplies linear-light RGB by 2^(EV × r²) at the source radius, with EV = value / 100; results above white clip.\n- Automatic scaling bisects the zoom (48 steps, 1028 border samples) for the widest view whose whole frame lies inside the photo. Past the radius where the polynomial stops increasing, and outside the photo with manual scale, pixels become transparent and are counted.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "lumina_lens_correct",
        "x-owner-app": "lumina",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LuminaLensCorrectInput"
              },
              "examples": {
                "example1": {
                  "summary": "Straighten a barrel-distorted grid",
                  "value": {
                    "image": {
                      "filename": "barrel-grid.png",
                      "contentType": "image/png",
                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dY8A7HWNw/SCIO4ANB0E8dpQG3T3ajtJAWmLhMBJ0nEu/w0huHOcir5+WUil8xJwuHogD3+J+B+IUjhS6A0g/d7Wu4OzGoUz8TxzKVDrWih5Rux9r9R/doF04dFjDfgAAAABJRU5ErkJggg=="
                    },
                    "distortion": 60
                  }
                },
                "example2": {
                  "summary": "Pincushion at a fixed 100 % scale (shows the transparent corners)",
                  "value": {
                    "image": {
                      "filename": "barrel-grid.png",
                      "contentType": "image/png",
                      "contentBase64": "iVBORw0KGgoAAAANSUhEUgAAAKAAAAB4CAMAAABCfAldAAAAJ1BMVEX08egzSGYXMFPQ0tB4hZSPmaQkO1u7v8Kts7hkc4fk491LXXYpP18ecNOIAAAGPUlEQVR42u2c25akKBBFBRER+f/vHW6akhIHUOyypyteKlcpsAXkcoxgGLLGOBvzVwbB+TSQJrmcyYuK80UT1xhf9VBvhr59uQ44A8CVrpKMaUnnVACUAHDk9HM3AsJH5YpOyUuAFMXCZQPgCGqpAMg5DWifm6ymCWb7bQoAspcAknczhFAClCSggl275XEk7CwS4ktpqLRjE6AAgwUG5AVACQBFPSB6pTg3lwEZ/eBo4DjbSkOgjh4AQV9nsOs0TCVgpnsM0LQBrqCv5DPS3mwvU/5HNvEKR4eGqSRb3VqP4zjbF5wJsSzLuq7MmjHSGd9s/+X/bYy9xd652gRimmwNinkcs/hNc52fih2QUtMkFodyYIBWd580jtsxKxWB6+a6wGTXA7KKSH6qKZqtwe2niZVblQ9b7fC1eNo81TS5evq0zzkH31S2ZW0TT+7Bnc2zbbDEbDFT+p95DvfaRJNLHPsGzS1d3doSIuuBKr0r8AgPEzFc37d9cMEzCXiL7WJXjHoj99Ai9uYssGUdkn4RkRaXj+c5d+cJD6h4mLGJxVdiX4jjdRkHXGYOsIM5dNbAhKfiTBlNgOTTudXCTru/nGbYoL7yIUsRTwGeVgsBloIgS3ErfhpQY0CFAUXtVLKAxQwGHIqA5HzWslpYwZhZAJTXAWULIL2iWu8AzmDX1LKcQfN2CVAiQ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j3XSSe3eAvzUkg6xSyHOKsvgAtj8ffMe4iT3a2fgQGzf4nXalDqdAfweoTZNxYkpq3c8cgqQoTQeKfcwMFeITjIaN1bpmrshNPHj5pZEJlbGJQYoF5m4UenCeOOlxCQyzwt4dRKVxJd3IpbGFeqm4NPjuRa77DUH4dN5lyXS4y5w8ZO6ZT4Oal7Q8vrlMdBRH8tsAiRvHnfvspy85dWtjPgadSy0mGw67ON6CDnek3QLIQf7l4IjNd6Vml5B+I8dY8A7HWNw/SCIO4ANB0E8dpQG3T3ajtJAWmLhMBJ0nEu/w0huHOcir5+WUil8xJwuHogD3+J+B+IUjhS6A0g/d7Wu4OzGoUz8TxzKVDrWih5Rux9r9R/doF04dFjDfgAAAABJRU5ErkJggg=="
                    },
                    "distortion": -30,
                    "vignette": 20,
                    "autoScale": false,
                    "scale": 100
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LuminaLensCorrectResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "LuminaLensCorrectInput": {
        "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"
              }
            }
          },
          "distortion": {
            "title": "Distortion (positive corrects barrel, negative pincushion)",
            "description": "−100 to 100. The radial term k1 = −0.0025 × value.",
            "type": "number",
            "minimum": -100,
            "maximum": 100,
            "default": 25
          },
          "edge": {
            "title": "Edge distortion (extra correction near the corners)",
            "description": "−100 to 100. The 4th-order term k2 = −0.001 × value.",
            "type": "number",
            "minimum": -100,
            "maximum": 100,
            "default": 0
          },
          "red": {
            "title": "Red fringe (positive shrinks the red channel)",
            "description": "−100 to 100; 100 scales the red channel radius by 0.2 %.",
            "type": "number",
            "minimum": -100,
            "maximum": 100,
            "default": 0
          },
          "blue": {
            "title": "Blue fringe (positive shrinks the blue channel)",
            "description": "−100 to 100; 100 scales the blue channel radius by 0.2 %.",
            "type": "number",
            "minimum": -100,
            "maximum": 100,
            "default": 0
          },
          "vignette": {
            "title": "Corner brightness (EV × 100 in the corners)",
            "description": "−100 to 100; 100 brightens the corners by one stop in linear light.",
            "type": "number",
            "minimum": -100,
            "maximum": 100,
            "default": 0
          },
          "autoScale": {
            "title": "Fill the frame automatically",
            "type": "boolean",
            "default": true
          },
          "scale": {
            "title": "Manual scale (%) when automatic scaling is off",
            "type": "number",
            "minimum": 50,
            "maximum": 200,
            "default": 100
          }
        },
        "required": [
          "image"
        ]
      },
      "LuminaLensCorrectResult": {
        "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",
              "settings",
              "zoom",
              "automatic",
              "outsidePixels",
              "report"
            ],
            "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)."
                  }
                }
              },
              "settings": {
                "type": "object"
              },
              "zoom": {
                "type": "number"
              },
              "automatic": {
                "type": "boolean"
              },
              "outsidePixels": {
                "type": "integer"
              },
              "report": {
                "type": "object"
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}