LinuxCommandLibrary

compare

image difference detection and comparison

TLDR

Compare two images

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

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.

METRICS

AE: Absolute Error (pixel count)
RMSE: Root Mean Square Error
MAE: Mean Absolute Error
PSNR: Peak Signal to Noise Ratio
SSIM: Structural Similarity Index

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)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community