{
  "slug": "image-resize-to-filesize",
  "name": "gizza-ai/image-resize-to-filesize",
  "version": "0.1.0",
  "title": "Compress Image to a Target File Size (KB) — gizza.ai",
  "description": "Compress a JPG or WebP to a target file size in KB. Enter a KB budget and it searches the best quality that fits — all in your browser, nothing uploaded, free.",
  "tags": [
    "image",
    "compress",
    "file size",
    "kb",
    "target size",
    "jpeg",
    "webp",
    "reduce"
  ],
  "category": "image",
  "urls": {
    "page": "https://gizza.ai/tools/image-resize-to-filesize/",
    "markdown": "https://gizza.ai/tools/image-resize-to-filesize/index.md",
    "descriptor": "https://gizza.ai/tools/image-resize-to-filesize/tool.json",
    "deep_link_example": "https://gizza.ai/tools/image-resize-to-filesize/?url=https://example.com/input&target_kb=200&format=jpg&max_width=0"
  },
  "cli": "gizza tool image-resize-to-filesize 'url=https://example.com/input' 'target_kb=200' 'format=jpg' 'max_width=0'",
  "tool": {
    "description": "Compress an image to a target file size in KB. Provide either url (HTTP/HTTPS) or ref (id from a prior image tool call), a target_kb budget, and optionally format (jpg/webp) and max_width. The tool binary-searches the encoder quality for the highest quality whose file is at or under target_kb, optionally shrinking the width first. Output is JPEG or WebP (PNG has no quality knob to search).",
    "parameters": {
      "additionalProperties": false,
      "oneOf": [
        {
          "required": [
            "url"
          ]
        },
        {
          "required": [
            "ref"
          ]
        }
      ],
      "properties": {
        "format": {
          "default": "jpg",
          "description": "Output format for the lossy quality search: \"jpg\" (widest support) or \"webp\" (smaller at equal quality). Default jpg.",
          "enum": [
            "jpg",
            "webp"
          ],
          "type": "string"
        },
        "max_width": {
          "default": 0,
          "description": "Optional cap on output width in pixels (0 = keep original size). Shrinks only, never upscales. Use a smaller value when the target can't be reached at full resolution.",
          "minimum": 0,
          "type": "integer"
        },
        "ref": {
          "description": "Reference id from a prior tool call. Use either url or ref.",
          "type": "string"
        },
        "target_kb": {
          "description": "Target maximum output size in KB, e.g. 200. The tool searches the highest encoder quality whose file is at or under this budget (1 MB = 1024 KB).",
          "minimum": 1,
          "type": "number"
        },
        "url": {
          "description": "Image URL (HTTP/HTTPS). Use either url or ref.",
          "type": "string"
        }
      },
      "required": [
        "target_kb"
      ],
      "type": "object"
    }
  }
}