{
  "openapi": "3.1.1",
  "info": {
    "title": "Image Shape Mask & Feather API",
    "version": "1.0.0",
    "summary": "Clip a photo into a soft rectangle or ellipse with PNG transparency.",
    "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://luminaimagemask.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Clip a photo into a soft rectangle or ellipse with PNG transparency.",
        "description": "Upload a photo and apply a rectangular or elliptical alpha mask with adjustable bounds, inward feathering and inversion. Download a transparent PNG while preserving the original image dimensions.\n\nMethodology:\n- The source is auto-oriented and converted to sRGB. Its existing alpha is multiplied by mask coverage. Source dimensions are preserved; metadata is stripped.\n- Rectangle distance uses the nearest edge; ellipse distance uses normalized radial distance scaled by the smaller radius. Feather transitions inward with smoothstep; it approximates distance for noncircular ellipses.\n- Inputs are limited to 4 MP. GIF uses its first frame. This is a geometric mask, not automatic subject detection. The browser Design Layers mode uses the same mask engine.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "lumina_image_mask",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LuminaImageMaskInput"
              },
              "examples": {
                "example1": {
                  "summary": "A circular transparent cutout",
                  "value": {
                    "image": {
                      "filename": "sample.png",
                      "contentType": "image/png",
                      "contentBase64": "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgAQMAAABJtOi3AAAABlBMVEX/////AADrWueTAAAAEklEQVQI12NgIBb8/09dgjgAAPcnH+GApkH4AAAAAElFTkSuQmCC"
                    },
                    "shape": "ellipse",
                    "feather": 3
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LuminaImageMaskResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "LuminaImageMaskInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "image": {
            "title": "Photo (PNG, JPEG, WebP or GIF)",
            "type": "object",
            "description": "Upload as {filename, contentType?, contentBase64}. Max 11719 KiB. Accepts .png,.jpg,.jpeg,.webp,.gif.",
            "additionalProperties": false,
            "required": [
              "filename",
              "contentBase64"
            ],
            "properties": {
              "filename": {
                "type": "string"
              },
              "contentType": {
                "type": "string"
              },
              "contentBase64": {
                "type": "string"
              }
            }
          },
          "shape": {
            "title": "Mask shape",
            "type": "string",
            "enum": [
              "ellipse",
              "rect"
            ],
            "default": "ellipse"
          },
          "x": {
            "title": "Mask left (%)",
            "type": "number",
            "minimum": 0,
            "maximum": 99,
            "default": 0
          },
          "y": {
            "title": "Mask top (%)",
            "type": "number",
            "minimum": 0,
            "maximum": 99,
            "default": 0
          },
          "width": {
            "title": "Mask width (%)",
            "type": "number",
            "minimum": 1,
            "maximum": 100,
            "default": 100
          },
          "height": {
            "title": "Mask height (%)",
            "type": "number",
            "minimum": 1,
            "maximum": 100,
            "default": 100
          },
          "feather": {
            "title": "Inward feather (normalized %)",
            "type": "number",
            "minimum": 0,
            "maximum": 25,
            "default": 0
          },
          "invert": {
            "title": "Invert mask",
            "type": "boolean",
            "default": false
          }
        },
        "required": [
          "image"
        ]
      },
      "LuminaImageMaskResult": {
        "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"
            ],
            "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)."
                  }
                }
              }
            }
          },
          "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"
              }
            }
          }
        }
      }
    }
  }
}