{
  "name": "image-convert",
  "summary": "Transcodes an image to PNG, JPEG or WebP at a chosen quality, returned base64-encoded.",
  "rationale": "Transcoding safely needs a real codec and a hardened fetch: an agent that pulls the URL itself walks past every SSRF control, and the output must be byte-reproducible, which an ad-hoc re-encode is not.",
  "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 source image, up to 2048 characters; redirects are followed and the source format is detected from the bytes."
      },
      "format": {
        "type": "string",
        "enum": [
          "png",
          "jpeg",
          "webp"
        ],
        "description": "Target format to encode to, png, jpeg or webp; the pixel dimensions are kept and metadata is dropped."
      },
      "quality": {
        "default": 80,
        "description": "Encoder quality from 1 to 100 for jpeg and webp output; ignored for png, which is always lossless.",
        "type": "integer",
        "minimum": 1,
        "maximum": 100
      }
    },
    "required": [
      "url",
      "format"
    ],
    "additionalProperties": false
  },
  "input_example": {
    "url": "https://grist.tools/samples/images/convert-gradient.png",
    "format": "webp",
    "quality": 80
  },
  "output_example": {
    "source_url": "https://grist.tools/samples/images/convert-gradient.png",
    "source_format": "png",
    "format": "webp",
    "mime_type": "image/webp",
    "width": 32,
    "height": 32,
    "bytes": 156,
    "image_base64": "UklGRpQAAABXRUJQVlA4IIgAAAAQBQCdASogACAALk02m02hJCQkBABMS2AE6ZiX..."
  },
  "errors": [
    "invalid_input",
    "blocked_target",
    "unreachable_target",
    "upstream_timeout",
    "unsupported_content_type",
    "too_large",
    "unprocessable",
    "internal"
  ]
}