Skip to main content
Glama

Compress image

compress_image

Compress local JPEG, WebP, or AVIF images to a chosen quality or target file size, returning before/after sizes.

Instructions

Re-encode a local image with a chosen quality/compression level, or binary-search the highest quality that fits target_size_bytes (JPEG, WebP, AVIF). Returns before/after sizes.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "image": "<image>"
    },
    "name": "compress_image"
  }
}

Input Schema

NameRequiredDescriptionDefault
imageYesAbsolute path to a local image on the machine running this MCP server.
qualityNoEncoder quality (1-100). Applies to JPEG, WebP, AVIF and TIFF output.
losslessNoUse lossless encoding where supported (WebP and AVIF).
file_nameNoOptional base file name; path separators are not allowed. The actual image format determines the extension. When multiple outputs are produced, -1, -2, ... suffixes are appended. Existing files are never overwritten.
backgroundNoCSS color used as the background, for example #ffffff or transparent.
output_dirNoAbsolute directory where the output file is saved. Defaults to IMG_OUTPUT_DIR, or ~/img-output. The directory is created automatically.
output_formatNoOutput format. Defaults to the input format (SVG input becomes PNG).
compression_levelNoPNG compression level (0-9); higher is smaller and slower.
target_size_bytesNoTarget maximum file size in bytes. Supported for JPEG, WebP and AVIF; quality is then chosen automatically. Returns the smallest attempt if the target cannot be reached.

Output Schema

NameRequiredDescriptionDefault
imageYes
sourceYes
detailsNo
operationYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.0.1

TDQS

A3.5/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations declare a non-read-only, non-idempotent, non-destructive operation, so the agent already knows files are produced. The description adds genuine context that it returns before/after sizes and that the target-size mode is a search with a fallback. It does not disclose write-location behavior or overwrite handling in the description itself (that detail lives only in the schema).

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two dense sentences, front-loaded with the core action and mode split, with zero filler. The parenthetical format list is the only slightly compressed detail, and it earns its place by constraining the target-size mode.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With an output schema covering the reported sizes and full schema descriptions on all nine parameters, the description carries only the conceptual load: what the tool does and its two modes. The main gap is guidance on when to prefer this over convert_image, given they share format-conversion surface area.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so parameter meaning is already well documented. The description contributes the higher-level relationship between quality and target_size_bytes (choose one mode or the other) and the format applicability of target sizing, but adds no syntax or constraints beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb and resource ('Re-encode a local image') and names the two operating modes: fixed quality/compression level or binary search toward a target size. It scopes the target-size mode to JPEG, WebP, and AVIF. It stops short of explicitly distinguishing itself from the sibling convert_image, which an agent may see as overlapping.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The two modes are clearly implied—pick a quality/compression level, or give target_size_bytes and let quality be chosen automatically—which tells an agent how to call it. However, there is no explicit when-to-use versus alternatives such as convert_image or resize_image, and no stated prerequisites beyond 'local image'.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.