compare

image difference detection and comparison

TLDR

Compare two images
$ compare [image1.png] [image2.png] [diff.png]
Highlight differences in red
$ compare -highlight-color red [image1.png] [image2.png] [diff.png]
Get difference metric
$ compare -metric AE [image1.png] [image2.png] null:
Compare with fuzz factor (tolerance)
$ compare -fuzz [5]% [image1.png] [image2.png] [diff.png]
Output only difference regions
$ compare -compose src [image1.png] [image2.png] [diff.png]
Use specific channel
$ compare -channel red [image1.png] [image2.png] [diff.png]

SYNOPSIS

compare [options] image1 image2 [difference]

DESCRIPTION

compare is an ImageMagick utility that compares two images and highlights the differences. It can output a visual difference image and/or calculate numeric difference metrics.The tool is useful for visual regression testing, detecting changes in rendered output, and quality assurance workflows. Various metrics quantify the difference between images.

PARAMETERS

-metric type

Output difference metric (AE, RMSE, MAE, PSNR, etc.).
-fuzz percent
Allow color tolerance for comparison.
-highlight-color color
Color to use for highlighting differences.
-lowlight-color color
Color for matching areas.
-compose method
Composition method for difference output.
-channel type
Compare specific color channel.
-subimage-search
Search for subimage in larger image.
-dissimilarity-threshold value
Threshold for subimage matching.
-verbose
Display detailed comparison information and computed metrics.

METRICS

AE: Absolute Error (count of differing pixels)RMSE: Root Mean Square Error (0 = identical)MAE: Mean Absolute Error (0 = identical)MSE: Mean Squared ErrorPSNR: Peak Signal to Noise Ratio (higher = more similar)SSIM: Structural Similarity Index (1 = identical)NCC: Normalized Cross Correlation (default metric)PHASH: Perceptual Hash

INSTALL

sudo pacman -S imagemagick
sudo apk add imagemagick
brew install imagemagick
nix profile install nixpkgs#imagemagick

CAVEATS

Images must be same dimensions unless using subimage search. Large images can be slow to compare. Lossy formats may show differences from compression.

HISTORY

compare is part of ImageMagick, created by John Cristy in 1987. ImageMagick has been continuously developed for image manipulation and conversion. The compare tool became essential for automated visual testing in software development.

SEE ALSO

magick(1), convert(1), identify(1), diff(1)