{
  "openapi": "3.1.1",
  "info": {
    "title": "Photo Crop & Resize Planner API",
    "version": "1.0.0",
    "summary": "Plan a precise crop and output size before resizing 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://luminaresizeplanner.usefulweb.app"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Plan a precise crop and output size before resizing a photo.",
        "description": "Calculate a centered crop, final pixel dimensions and scale for a target box. Fit keeps the whole image; fill crops to the requested aspect ratio. Upscaling is optional.\n\nMethodology:\n- Fit uses the smaller target/source scale; fill uses the larger one and a centered crop.\n- When enlargement is disabled, scale is capped at 1. Pixel coordinates and output dimensions are rounded to whole pixels.",
        "tags": [
          "apps"
        ],
        "x-mcp-tool": "lumina_resize_planner",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LuminaResizePlannerInput"
              },
              "examples": {
                "example1": {
                  "summary": "Square social photo",
                  "value": {
                    "width": 6000,
                    "height": 4000,
                    "targetWidth": 1080,
                    "targetHeight": 1080,
                    "mode": "cover",
                    "upscale": false
                  }
                },
                "example2": {
                  "summary": "Fit a small photo without enlargement",
                  "value": {
                    "width": 600,
                    "height": 400,
                    "targetWidth": 1920,
                    "targetHeight": 1080,
                    "mode": "contain"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/LuminaResizePlannerResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "LuminaResizePlannerInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "width": {
            "title": "Source width (px)",
            "type": "integer",
            "minimum": 1,
            "maximum": 100000,
            "default": 6000
          },
          "height": {
            "title": "Source height (px)",
            "type": "integer",
            "minimum": 1,
            "maximum": 100000,
            "default": 4000
          },
          "targetWidth": {
            "title": "Target width (px)",
            "type": "integer",
            "minimum": 1,
            "maximum": 100000,
            "default": 1080
          },
          "targetHeight": {
            "title": "Target height (px)",
            "type": "integer",
            "minimum": 1,
            "maximum": 100000,
            "default": 1080
          },
          "mode": {
            "title": "Fit mode",
            "type": "string",
            "enum": [
              "contain",
              "cover"
            ],
            "default": "cover"
          },
          "upscale": {
            "title": "Allow enlargement",
            "type": "boolean",
            "default": false
          }
        },
        "required": []
      },
      "LuminaResizePlannerResult": {
        "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",
              "scale",
              "crop",
              "megapixels",
              "upscaled"
            ],
            "properties": {
              "width": {
                "type": "integer"
              },
              "height": {
                "type": "integer"
              },
              "scale": {
                "type": "number"
              },
              "megapixels": {
                "type": "number"
              },
              "upscaled": {
                "type": "boolean"
              },
              "crop": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "x",
                  "y",
                  "width",
                  "height"
                ],
                "properties": {
                  "x": {
                    "type": "integer"
                  },
                  "y": {
                    "type": "integer"
                  },
                  "width": {
                    "type": "integer"
                  },
                  "height": {
                    "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"
              }
            }
          }
        }
      }
    }
  }
}