{
  "name": "svg-to-png",
  "summary": "Rasterises an SVG to a PNG at a chosen resolution, returned base64-encoded.",
  "rationale": "Rasterising an SVG safely needs a real renderer and a hardened fetch: an SVG can point at internal addresses, so an agent that renders one itself walks past every SSRF control, and the output must be byte-reproducible.",
  "family": "images",
  "price_usd": "0.003",
  "free": false,
  "timeout_ms": 60000,
  "max_timeout_seconds": 81,
  "input_schema": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "url": {
        "type": "string",
        "maxLength": 2048,
        "format": "uri",
        "description": "Absolute http(s) URL of the SVG, up to 2048 characters; redirects are followed and the body must look like SVG markup; external references in it are never fetched."
      },
      "width": {
        "description": "Target width in pixels, 1 to 20000; when width or height is set the rendered raster is resized to fit inside that box, keeping its aspect ratio, and may be scaled up.",
        "type": "integer",
        "minimum": 1,
        "maximum": 20000
      },
      "height": {
        "description": "Target height in pixels, 1 to 20000; when width or height is set the rendered raster is resized to fit inside that box, keeping its aspect ratio, and may be scaled up.",
        "type": "integer",
        "minimum": 1,
        "maximum": 20000
      },
      "density": {
        "default": 96,
        "description": "Render resolution in DPI, 1 to 2400, default 96; the natural raster size scales with density / 72, so a 64-unit-wide SVG renders 85 pixels wide at 96.",
        "type": "integer",
        "minimum": 1,
        "maximum": 2400
      }
    },
    "required": [
      "url"
    ],
    "additionalProperties": false
  },
  "input_example": {
    "url": "https://grist.tools/samples/images/svg-badge.svg",
    "density": 192
  },
  "output_example": {
    "source_url": "https://grist.tools/samples/images/svg-badge.svg",
    "format": "png",
    "width": 171,
    "height": 128,
    "bytes": 2021,
    "image_base64": "iVBORw0KGgoAAAANSUhEUgAAAKsAAACACAYAAAB0g5nsAAAACXBIWXMAAB2HAAAd..."
  },
  "errors": [
    "invalid_input",
    "blocked_target",
    "unreachable_target",
    "upstream_timeout",
    "unsupported_content_type",
    "too_large",
    "unprocessable",
    "internal"
  ]
}