compare_revisions
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
| Name | Required | Description | Default |
|---|---|---|---|
| layout | No | `"side_by_side"`(既定、水平に並べる)| `"stacked"`(垂直に並べる)| `"diff"`(並べる代わりに1枚の差分ヒートマップを作る。A/B の寸法が完全一致している必要がある)。 | side_by_side |
| revision_id_a | Yes | 比較対象 A の revision ID("rev_...")。合成画像の左(または上)に置かれる。 | |
| revision_id_b | Yes | 比較対象 B の revision ID("rev_...")。合成画像の右(または下)に置かれる。 |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| a | Yes | ||
| b | Yes | ||
| ssim | No | Structural 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. | |
| width | Yes | 合成画像(比較プレビュー)の寸法・容量。 | |
| height | Yes | ||
| layout | Yes | ||
| byte_size | Yes | ||
| mime_type | Yes | ||
| a_position | Yes | A が合成画像のどこに置かれるか("left" | "top")。 | |
| b_position | Yes | B が合成画像のどこに置かれるか("right" | "bottom")。 | |
| max_abs_diff | No | `layout: "diff"` のときだけ載る: 画素ごとのチャンネル最大絶対差 d の、全画素中の最大値。 | |
| preview_path | Yes | 比較プレビュー画像の絶対パス。 | |
| mean_abs_diff | No | `layout: "diff"` のときだけ載る: 全チャンネル・全画素平均の絶対差(0..255 スケール)。 | |
| changed_pixel_ratio | No | `layout: "diff"` のときだけ載る: d > 2 の画素が全体に占める割合(0.0..=1.0)。 | |
| perceptual_hash_distance | No | Hamming 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. |