Skip to main content
Glama

compare_revisions

Idempotent

Compare two image revisions side by side, stacked, or as a pixel-difference heatmap. Returns JPEG composites with SSIM and perceptual hash distance for A/B checks.

Instructions

Scale two revisions to a long edge of 640px each and compose them on one canvas (side by side, or stacked) with an 8px gap, returned inline as a JPEG. A is placed left/top, B is placed right/bottom. Useful for before/after or A/B visual checks. layout="diff" instead requires A and B to share the exact same dimensions and returns a single pixel-difference heatmap plus mean_abs_diff/max_abs_diff/changed_pixel_ratio and an ssim score (structural similarity, 1.0 = identical). Every layout also reports perceptual_hash_distance: the Hamming distance between the two dHash values (0..=64), where 5 or less usually means the same picture re-encoded or resized and 20 or more means two different pictures.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
layoutNo`"side_by_side"`(既定、水平に並べる)| `"stacked"`(垂直に並べる)| `"diff"`(並べる代わりに1枚の差分ヒートマップを作る。A/B の寸法が完全一致している必要がある)。side_by_side
revision_id_aYes比較対象 A の revision ID("rev_...")。合成画像の左(または上)に置かれる。
revision_id_bYes比較対象 B の revision ID("rev_...")。合成画像の右(または下)に置かれる。

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
aYes
bYes
ssimNoStructural similarity (SSIM, 0..=1) over the two images' luma. Present only with `layout: "diff"` and equal dimensions. 1.0 is pixel-identical; above ~0.98 the difference is usually invisible; below ~0.9 it is a visible change of content.
widthYes合成画像(比較プレビュー)の寸法・容量。
heightYes
layoutYes
byte_sizeYes
mime_typeYes
a_positionYesA が合成画像のどこに置かれるか("left" | "top")。
b_positionYesB が合成画像のどこに置かれるか("right" | "bottom")。
max_abs_diffNo`layout: "diff"` のときだけ載る: 画素ごとのチャンネル最大絶対差 d の、全画素中の最大値。
preview_pathYes比較プレビュー画像の絶対パス。
mean_abs_diffNo`layout: "diff"` のときだけ載る: 全チャンネル・全画素平均の絶対差(0..255 スケール)。
changed_pixel_ratioNo`layout: "diff"` のときだけ載る: d > 2 の画素が全体に占める割合(0.0..=1.0)。
perceptual_hash_distanceNoHamming distance (0..=64) between the two revisions' perceptual hashes (dHash), on every layout. 0 means the thumbnails are identical; 5 or less usually means the same picture re-encoded or resized; 20 or more means different pictures. Null when either side's pixels could not be hashed.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv0.6.4
    • addedOutput schema / properties / perceptual_hash_distance
      Added value: +{
      +  "description": "Hamming distance (0..=64) between the two revisions' perceptual hashes (dHash),\non every layout. 0 means the thumbnails are identical; 5 or less usually means\nthe same picture re-encoded or resized; 20 or more means different pictures.\nNull when either side's pixels could not be hashed.",
      +  "format": "uint32",
      +  "minimum": 0,
      +  "type": [
      +    "integer",
      +    "null"
      +  ]
      +}
    • addedOutput schema / properties / ssim
      Added value: +{
      +  "description": "Structural similarity (SSIM, 0..=1) over the two images' luma. Present only with\n`layout: \"diff\"` and equal dimensions. 1.0 is pixel-identical; above ~0.98 the\ndifference is usually invisible; below ~0.9 it is a visible change of content.",
      +  "format": "double",
      +  "type": [
      +    "number",
      +    "null"
      +  ]
      +}
  2. First observedv0.5.2

TDQS

A4.6/5.0
Behavior5/5

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

Despite annotations covering safety, the description adds substantial behavioral detail the annotations cannot: the 640px scaling, 8px gap, A/B placement order, JPEG inline return, diff's dimension precondition, and how to interpret perceptual_hash_distance thresholds. This is rich context beyond structured fields.

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?

Front-loaded with the core behavior, then layers diff and metric semantics. Dense and mostly earning its length, though the metric-threshold sentences could be trimmed without losing the essential call information.

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

Completeness5/5

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

For a three-parameter compose tool with an output schema, the description covers layout semantics, output format, preconditions, and metric interpretation. Nothing an agent needs to invoke or interpret it correctly is missing.

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

Parameters4/5

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

Schema coverage is 100%, so the baseline is 3, but the description adds meaning: it explains which layout is default, the placement convention (A left/top, B right/bottom), and the semantic thresholds for the computed distance metrics, going beyond the schema's field docs.

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

Purpose5/5

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

States specific actions (scale to 640px, compose on one canvas, return JPEG) with a precise resource (two revisions), and it explicitly distinguishes its three layouts including what diff does differently. An agent can tell exactly what this produces.

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

Usage Guidelines4/5

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

Gives the trigger context ('useful for before/after or A/B visual checks') and the precondition that diff requires identical dimensions. It does not name or contrast sibling tools, but the when-to-use conditions are clear.

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