{
  "openapi": "3.1.1",
  "info": {
    "title": "Spot Healing \u0026 Clone Stamp API",
    "version": "1.0.0",
    "summary": "Remove dust spots and blemishes with seamless healing or a clone stamp.",
    "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://luminaspotheal.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Remove dust spots and blemishes with seamless healing or a clone stamp.",
        "description": "Upload a photo and a list of brush strokes. Heal strokes replace a spot with texture from a nearby area and blend it seamlessly into the surrounding colour and brightness (Poisson-style seamless cloning); clone strokes copy pixels exactly from a source area. Leave out the source of a heal stroke and the tool picks the best-matching nearby area. Download a PNG plus the resolved strokes as JSON for the Lumina photo editor, where they stay editable.\n\nMethodology:\n- Auto-oriented, display-referred 8-bit sRGB. Points and source offsets are fractions of the width and height; the radius is a fraction of the longer side, so the same strokes fit any size of the photo.\n- Strokes run in order; each one sees the result of the previous strokes. Heal without a source picks one automatically.\n- Brush mask: distance from each pixel centre to the stroke path; fully on up to radius × hardness, then a smoothstep fall-off to zero at the radius. Source pixels are sampled bilinearly (clamped to the photo edge) at the stroke position plus the offset.\n- Clone blends the source pixels in with mask × opacity. Heal solves the Poisson equation of seamless cloning (Pérez, Gangnet \u0026 Blake 2003) as a membrane: result = source + c, where c is harmonic inside the stroke and equals target − source just outside it. The 5-point Laplace system is solved per colour channel with conjugate gradients from a coarse-grid starting value (relative residual 10⁻⁴, at most 400 iterations).\n- Automatic source: 48 candidate offsets (16 directions × 2.2, 3 and 4 stroke radii) inside the photo; the one whose surroundings best match the ring just outside the stroke (mean squared RGB difference) wins, first candidate on ties.\n- Healing cannot invent content that exists nowhere in the photo: large objects on busy backgrounds need a hand-picked source or several smaller strokes. No AI or content-aware fill.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "lumina_spot_heal",
        "x-owner-app": "lumina",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LuminaSpotHealInput"
              },
              "examples": {
                "example1": {
                  "summary": "Remove four dust spots from a sky",
                  "value": {
                    "image": {
                      "filename": "dusty-sky.png",
                      "contentType": "image/png",
                      "contentBase64": "iVBORw0KGgoAAAANSUhEUgAAAKAAAAB4CAIAAAD6wG44AAADlUlEQVR42u2cPW/TUBiFr02k2l2iBttJYzdtfhNLFyaEGJioEBUUhYJaqgJSJwaEmJhZmPgDFBgQC6JISPSDJCVOSNXJjmRshqLIIDKQurJz/Tzy4Nwhcu/Je+65H66y9eqjAHkpCBHRCzILrNAHkguMwlQwIDBkNmShsOwVTIrGooEUDVQwpIBKF2DRgEUD0yTAooGQBYzBgEVTwUCKhskQmO1CLBoQGEjRQAVD8rCSJb9FM03CogGBgRQNVDCQogGLhj8smmkSYzBg0ckShmH/sOke7Fq1emnWUVWywrgCZ/CZjnudF1v3jnudk49Fo3zhWqNolFFrnBStCJGpS0RhXN2h3iIKs/aoE3FlzqJ/tJtxdYca9w+bhl2jIic+RbsHX0e1m/Ycgk18ii7X6qPaCfxjhayMdZtRdYqGddxz441FwzKqDucDZQhZqqouLjWKhhVXd3GpoaoqiWmc6+X2+wz+7qIo7LWbnYPdcq1uVB1FYR4s10KHoqiWU7McYrN0IQsSX8liswGLBiwaEBiwaEh8oYMukN6iSdFYNBCyAIEhDYHZg6OCAYEhwymaaRIVDAgMYRS6rVZ7f7c6X7dsW83GKRRSdDIcue6zzbV+9/dZwZJpXVq+PWNZqT8YJ9mSeBsjDOPqCiH6XffZ5poIwwy82UD1nZpOuxlXd6ix225W0j5Wxlp0ArT390a1z86lLjC7SafGnl8Y1Z5697IfnAAVxymZf+epkmlVHCf1Z1O2P7xDodPTd90nG+vxFH3l5kopAylaeYPACRGF4fdWq7W/Z88vVGxbycZ/JVDeIrDUkKJlF5g3G2SvYPoAiwYqGBAY0glZKEwFw0QLzDSJFA1YNGQTtguxaMCiIXcpOgiCo15vxjAKhQK9LJtFB0Hw4Mb1k/vlh4/QWLaQddTt/vMeJBmDz5tm/D4jw7zveZqu501gZefT9ll8788g6He7JdM8lwF/bn9rrd+6M/D9KU1buX+3OmfnSODPZyNwdohEdPXi5YHvn3yc0rTHz58qudljkX+a5HveUF0hxMD3B56n69P5SdGSbzbouj6lafEK1nU9P6+9y79UqSiisbGqaZoQQtO0xsZqrhbvlC87r3Pyp3qep+cvRedoLXp6OnfqCtaiERgmXGAO3UlfwZzJwqKBFA1UMKQAh+6waCBFA2MwYNFAyAIsGrBoKhiYJsGECMx2IRYNCAykaKCCgQqG/+QXnUXwvGFlADYAAAAASUVORK5CYII="
                    },
                    "strokes": "[{\"mode\":\"heal\",\"points\":[[0.325,0.333]],\"radius\":0.03},{\"mode\":\"heal\",\"points\":[[0.7,0.55]],\"radius\":0.03},{\"mode\":\"heal\",\"points\":[[0.4875,0.7667]],\"radius\":0.025},{\"mode\":\"clone\",\"points\":[[0.1875,0.733]],\"radius\":0.02,\"source\":[0.08,0]}]"
                  }
                },
                "example2": {
                  "summary": "Clone one spot from a fixed offset",
                  "value": {
                    "image": {
                      "filename": "dusty-sky.png",
                      "contentType": "image/png",
                      "contentBase64": "iVBORw0KGgoAAAANSUhEUgAAAKAAAAB4CAIAAAD6wG44AAADlUlEQVR42u2cPW/TUBiFr02k2l2iBttJYzdtfhNLFyaEGJioEBUUhYJaqgJSJwaEmJhZmPgDFBgQC6JISPSDJCVOSNXJjmRshqLIIDKQurJz/Tzy4Nwhcu/Je+65H66y9eqjAHkpCBHRCzILrNAHkguMwlQwIDBkNmShsOwVTIrGooEUDVQwpIBKF2DRgEUD0yTAooGQBYzBgEVTwUCKhskQmO1CLBoQGEjRQAVD8rCSJb9FM03CogGBgRQNVDCQogGLhj8smmkSYzBg0ckShmH/sOke7Fq1emnWUVWywrgCZ/CZjnudF1v3jnudk49Fo3zhWqNolFFrnBStCJGpS0RhXN2h3iIKs/aoE3FlzqJ/tJtxdYca9w+bhl2jIic+RbsHX0e1m/Ycgk18ii7X6qPaCfxjhayMdZtRdYqGddxz441FwzKqDucDZQhZqqouLjWKhhVXd3GpoaoqiWmc6+X2+wz+7qIo7LWbnYPdcq1uVB1FYR4s10KHoqiWU7McYrN0IQsSX8liswGLBiwaEBiwaEh8oYMukN6iSdFYNBCyAIEhDYHZg6OCAYEhwymaaRIVDAgMYRS6rVZ7f7c6X7dsW83GKRRSdDIcue6zzbV+9/dZwZJpXVq+PWNZqT8YJ9mSeBsjDOPqCiH6XffZ5poIwwy82UD1nZpOuxlXd6ix225W0j5Wxlp0ArT390a1z86lLjC7SafGnl8Y1Z5697IfnAAVxymZf+epkmlVHCf1Z1O2P7xDodPTd90nG+vxFH3l5kopAylaeYPACRGF4fdWq7W/Z88vVGxbycZ/JVDeIrDUkKJlF5g3G2SvYPoAiwYqGBAY0glZKEwFw0QLzDSJFA1YNGQTtguxaMCiIXcpOgiCo15vxjAKhQK9LJtFB0Hw4Mb1k/vlh4/QWLaQddTt/vMeJBmDz5tm/D4jw7zveZqu501gZefT9ll8788g6He7JdM8lwF/bn9rrd+6M/D9KU1buX+3OmfnSODPZyNwdohEdPXi5YHvn3yc0rTHz58qudljkX+a5HveUF0hxMD3B56n69P5SdGSbzbouj6lafEK1nU9P6+9y79UqSiisbGqaZoQQtO0xsZqrhbvlC87r3Pyp3qep+cvRedoLXp6OnfqCtaiERgmXGAO3UlfwZzJwqKBFA1UMKQAh+6waCBFA2MwYNFAyAIsGrBoKhiYJsGECMx2IRYNCAykaKCCgQqG/+QXnUXwvGFlADYAAAAASUVORK5CYII="
                    },
                    "strokes": "[{\"mode\":\"clone\",\"points\":[[0.325,0.333],[0.35,0.34]],\"radius\":0.03,\"hardness\":0.8,\"source\":[0.12,0]}]"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LuminaSpotHealResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "LuminaSpotHealInput": {
        "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"
              }
            }
          },
          "strokes": {
            "title": "Strokes (JSON list, or a Lumina project with \"retouch\")",
            "description": "Each stroke: {\"mode\":\"heal\"|\"clone\",\"points\":[[x,y],…],\"radius\":0.03,\"hardness\":0.5,\"opacity\":1,\"source\":[dx,dy]}. x, y, dx and dy are fractions of width and height (0.5 = middle); radius is a fraction of the longer side (0.002–0.15). Heal strokes may omit \"source\". Up to 200 strokes, 400 points each, 8000 in total.",
            "type": "string",
            "maxLength": 400000,
            "default": "[{\"mode\":\"heal\",\"points\":[[0.325,0.333]],\"radius\":0.03},{\"mode\":\"heal\",\"points\":[[0.7,0.55]],\"radius\":0.03},{\"mode\":\"heal\",\"points\":[[0.4875,0.7667]],\"radius\":0.025},{\"mode\":\"clone\",\"points\":[[0.1875,0.733]],\"radius\":0.02,\"source\":[0.08,0]}]"
          }
        },
        "required": [
          "image",
          "strokes"
        ]
      },
      "LuminaSpotHealResult": {
        "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",
              "strokes",
              "strokeCount",
              "autoSources",
              "changedPixels",
              "sha256Rgba"
            ],
            "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)."
                  }
                }
              },
              "strokes": {
                "type": "array",
                "maxItems": 200,
                "description": "Retouch strokes (clone stamp / spot healing), applied in order after lens correction and before crop. Points and source offsets are fractions of the photo width/height; radius is a fraction of the longer side. Up to 400 points per stroke and 8000 in total.",
                "items": {
                  "type": "object",
                  "required": [
                    "mode",
                    "points",
                    "radius",
                    "source"
                  ],
                  "properties": {
                    "id": {
                      "type": "string",
                      "maxLength": 80
                    },
                    "mode": {
                      "enum": [
                        "heal",
                        "clone"
                      ]
                    },
                    "points": {
                      "type": "array",
                      "minItems": 1,
                      "maxItems": 400,
                      "items": {
                        "type": "array",
                        "minItems": 2,
                        "maxItems": 2,
                        "items": {
                          "type": "number",
                          "minimum": 0,
                          "maximum": 1
                        }
                      }
                    },
                    "radius": {
                      "type": "number",
                      "minimum": 0.002,
                      "maximum": 0.15
                    },
                    "hardness": {
                      "type": "number",
                      "minimum": 0,
                      "maximum": 1
                    },
                    "opacity": {
                      "type": "number",
                      "minimum": 0.05,
                      "maximum": 1
                    },
                    "source": {
                      "type": "array",
                      "minItems": 2,
                      "maxItems": 2,
                      "items": {
                        "type": "number",
                        "minimum": -1,
                        "maximum": 1
                      },
                      "description": "Offset from every stroke point to the source area (fractions of width and height)."
                    }
                  }
                }
              },
              "strokeCount": {
                "type": "integer"
              },
              "autoSources": {
                "type": "integer",
                "description": "Heal strokes whose source was chosen automatically."
              },
              "changedPixels": {
                "type": "integer"
              },
              "sha256Rgba": {
                "type": "string",
                "description": "SHA-256 of the retouched RGBA pixels (row-major, 8-bit) for consistency checks with the Lumina editor."
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}