{
  "name": "image-compress",
  "summary": "Re-encodes an image in its own format at a lower quality to shrink the file, keeping its dimensions.",
  "rationale": "Compressing 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 a JPEG, PNG, WebP or GIF image, up to 2048 characters; redirects are followed and the output keeps the source format and dimensions."
      },
      "quality": {
        "default": 75,
        "description": "Encoder quality from 1 to 100, lower gives a smaller file; drives JPEG and WebP re-compression and PNG palette quantisation, and is ignored for GIF.",
        "type": "integer",
        "minimum": 1,
        "maximum": 100
      }
    },
    "required": [
      "url"
    ],
    "additionalProperties": false
  },
  "input_example": {
    "url": "https://grist.tools/samples/images/compress-scene.jpg",
    "quality": 60
  },
  "output_example": {
    "source_url": "https://grist.tools/samples/images/compress-scene.jpg",
    "format": "jpeg",
    "width": 96,
    "height": 64,
    "source_bytes": 1836,
    "bytes": 758,
    "saved_bytes": 1078,
    "ratio": 0.4129,
    "image_base64": "/9j/2wBDAA0JCgsKCA0LCgsODg0PEyAVExISEyccHhcgLikxMC4pLSwzOko+MzZG..."
  },
  "errors": [
    "invalid_input",
    "blocked_target",
    "unreachable_target",
    "upstream_timeout",
    "unsupported_content_type",
    "too_large",
    "unprocessable",
    "internal"
  ]
}