{
  "openapi": "3.1.1",
  "info": {
    "title": "HEIC/RAW Image Converter API",
    "version": "1.0.0",
    "summary": "Convert iPhone HEIC, AVIF and camera RAW (CR2, CR3, NEF, ARW, DNG…) to JPG, PNG or WebP.",
    "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://heicrawconverter.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Convert iPhone HEIC, AVIF and camera RAW (CR2, CR3, NEF, ARW, DNG…) to JPG, PNG or WebP.",
        "description": "Decodes HEIC/HEIF and AVIF photos with libheif and camera RAW files with LibRaw, applies the camera rotation and saves a JPG, PNG or WebP at the quality you choose. Shows the camera, lens and exposure details, and keeps or removes the EXIF metadata as you prefer.\n\nMethodology:\n- The file type is detected from its content: HEIC/HEIF and AVIF by their ISO-BMFF brand, RAW by its TIFF/ORF/RW2/RAF/CR3 signature (for TIFF-based RAW such as NEF/ARW the file extension decides between RAW and plain TIFF).\n- HEIC/HEIF and AVIF are decoded with libheif (heif-convert/heif-dec), which applies the rotation and mirroring stored in the file. RAW files are developed with LibRaw (dcraw_emu): demosaicing (AHD), camera or automatic white balance, sRGB output, 8 bits per channel.\n- ImageMagick encodes JPG/PNG; WebP is encoded with libwebp (cwebp) when installed. Width, height and pixel count are checked before decoding (limit 100 megapixels).\n- With \"Keep EXIF\" on, exiftool copies EXIF/XMP/IPTC from the original into the new file (without embedded previews) and resets the Orientation tag when the pixels were rotated. Otherwise the output carries no metadata at all.\n- RAW development here is a neutral default rendering. A dedicated RAW editor (Lightroom, darktable, RawTherapee) gives more control over exposure, noise and colour.\n\nKeep your original HEIC/RAW file: converting to JPG or WebP discards detail and dynamic range.",
        "tags": [
          "media"
        ],
        "x-mcp-tool": "heic_raw_converter",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/HeicRawConverterInput"
              },
              "examples": {
                "example1": {
                  "summary": "AVIF photo to JPG",
                  "value": {
                    "file": {
                      "filename": "photo.avif",
                      "contentType": "image/avif",
                      "contentBase64": "AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUEAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAAC0AAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAABAAAAAMAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgSAAAAAAABNjb2xybmNseAABAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAADVtZGF0EgAKCDgM/thAQIGkMh8YAAooooQAxC02adqijwo4ID0p6Pgn+VaHUuOCSvH4"
                    },
                    "format": "jpeg",
                    "quality": 85
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HeicRawConverterResult"
                }
              }
            }
          },
          "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"
                }
              }
            }
          }
        }
      },
      "HeicRawConverterInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "file": {
            "title": "HEIC, AVIF or RAW photo",
            "description": "HEIC/HEIF (iPhone), AVIF or camera RAW (CR2, CR3, NEF, ARW, DNG, ORF, RW2, RAF, PEF…), max 50 MB and 100 megapixels. Deleted after processing; the result can be downloaded for about 2 hours. Upload as {filename, contentType?, contentBase64}. Max 51200 KiB. Accepts .heic,.heif,.avif,image/heic,image/heif,image/avif,.cr2,.cr3,.nef,.nrw,.arw,.dng,.orf,.rw2,.raf,.pef,.srw.",
            "type": "object",
            "additionalProperties": false,
            "required": [
              "filename",
              "contentBase64"
            ],
            "properties": {
              "filename": {
                "type": "string"
              },
              "contentType": {
                "type": "string"
              },
              "contentBase64": {
                "type": "string"
              }
            }
          },
          "format": {
            "title": "Output format",
            "type": "string",
            "enum": [
              "jpeg",
              "png",
              "webp"
            ],
            "default": "jpeg"
          },
          "quality": {
            "title": "Quality",
            "description": "For JPG and WebP. PNG is always lossless.",
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "default": 90
          },
          "keepExif": {
            "title": "Keep EXIF metadata (camera, date, GPS location)",
            "description": "Off removes all metadata, including the GPS location.",
            "type": "boolean",
            "default": false
          },
          "autoOrient": {
            "title": "Apply the camera rotation",
            "description": "Rotates the pixels upright. HEIC rotation is always applied because the HEIF format requires it.",
            "type": "boolean",
            "default": true
          },
          "rawWhiteBalance": {
            "title": "RAW white balance",
            "type": "string",
            "enum": [
              "camera",
              "auto"
            ],
            "default": "camera"
          }
        },
        "required": [
          "file"
        ]
      },
      "HeicRawConverterResult": {
        "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": [
              "inputFormat",
              "inputDetail",
              "outputFormat",
              "quality",
              "originalBytes",
              "outputBytes",
              "width",
              "height",
              "decoder",
              "encoder",
              "metadataKept",
              "camera",
              "gpsInOriginal",
              "artifact"
            ],
            "properties": {
              "inputFormat": {
                "type": "string",
                "enum": [
                  "heic",
                  "avif",
                  "raw"
                ]
              },
              "inputDetail": {
                "type": "string",
                "description": "e.g. HEIC, AVIF, DNG, CR3, NEF"
              },
              "outputFormat": {
                "type": "string",
                "enum": [
                  "jpeg",
                  "png",
                  "webp"
                ]
              },
              "quality": {
                "type": [
                  "integer",
                  "null"
                ]
              },
              "originalBytes": {
                "type": "integer"
              },
              "outputBytes": {
                "type": "integer"
              },
              "width": {
                "type": "integer"
              },
              "height": {
                "type": "integer"
              },
              "decoder": {
                "type": "string"
              },
              "encoder": {
                "type": "string"
              },
              "metadataKept": {
                "type": "boolean"
              },
              "gpsInOriginal": {
                "type": "boolean"
              },
              "camera": {
                "type": "object",
                "additionalProperties": false,
                "required": [
                  "make",
                  "model",
                  "lens",
                  "iso",
                  "exposureTime",
                  "fNumber",
                  "focalLength",
                  "dateTaken"
                ],
                "properties": {
                  "make": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "model": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "lens": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "iso": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "exposureTime": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "fNumber": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "focalLength": {
                    "type": [
                      "string",
                      "null"
                    ]
                  },
                  "dateTaken": {
                    "type": [
                      "string",
                      "null"
                    ]
                  }
                }
              },
              "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"
              }
            }
          }
        }
      }
    }
  }
}