{
  "name": "color-palette-extract",
  "summary": "Extracts an image's dominant colours as a small palette (hex, RGB and coverage fraction).",
  "rationale": "Extracting a palette safely needs a real decoder and a hardened fetch: an agent that pulls the URL itself walks past every SSRF control, and a byte-reproducible quantiser is not something an agent writes inline.",
  "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 image, up to 2048 characters; redirects are followed and the format is detected from the bytes, not the content-type."
      },
      "colors": {
        "default": 5,
        "description": "Maximum number of palette colours to return, 1 to 16, most common first; fewer come back when the image has fewer distinct colour buckets.",
        "type": "integer",
        "minimum": 1,
        "maximum": 16
      }
    },
    "required": [
      "url"
    ],
    "additionalProperties": false
  },
  "input_example": {
    "url": "https://grist.tools/samples/images/palette-bands.png",
    "colors": 5
  },
  "output_example": {
    "source_url": "https://grist.tools/samples/images/palette-bands.png",
    "source_format": "png",
    "sample_size": 64,
    "count": 5,
    "dominant": "#3b4a5a",
    "colors": [
      {
        "hex": "#3b4a5a",
        "rgb": [
          59,
          74,
          90
        ],
        "fraction": 0.375
      },
      {
        "hex": "#d8c9a3",
        "rgb": [
          216,
          201,
          163
        ],
        "fraction": 0.25
      },
      {
        "hex": "#2f8f83",
        "rgb": [
          47,
          143,
          131
        ],
        "fraction": 0.1875
      },
      {
        "hex": "#e0735a",
        "rgb": [
          224,
          115,
          90
        ],
        "fraction": 0.125
      },
      {
        "hex": "#f4efe6",
        "rgb": [
          244,
          239,
          230
        ],
        "fraction": 0.0625
      }
    ]
  },
  "errors": [
    "invalid_input",
    "blocked_target",
    "unreachable_target",
    "upstream_timeout",
    "unsupported_content_type",
    "too_large",
    "unprocessable",
    "internal"
  ]
}