Skip to main content

Compare images

Compare two pictures pixel by pixel: whether they are the same, how much differs, where, and optionally a copy of the first with the changes in red.

Command in the Image recognition toolkit · id ooa.image/compare_images · 6 inputs (2 required), 5 outputs

Inputs​

InputTypeRequiredDefaultWhat it is
ImageFileYesFirst picture, e.g. the approved layout (PNG, JPG, BMP or GIF).
OtherFileYesSecond picture, e.g. a screen capture saved by an earlier step.
ToleranceNumberNo10How different one pixel's colour may be and still count as the same, in percent (0 = exact); ignores compression noise and slight colour shifts.
Maximum difference percentNumberNo0Share of pixels that may differ while the pictures still count as the same.
Size mismatchStringNoerrorWhen the sizes differ: error stops with IMAGE.SIZE_MISMATCH; scale stretches the second picture to the first one's size first.
Difference imageFileNoSave a PNG copy of the first picture with the changed pixels in red here; none when empty.

Outputs​

OutputTypeWhat it is
sameBooleanTrue when no more than max_difference_percent of the pixels differ.
difference_percentNumberShare of pixels that differ, 0 to 100, two decimals.
changed_pixelsNumberNumber of pixels that differ.
changed_areaDictionaryx, y, width and height of the box around every changed pixel (in the first image); empty when nothing changed.
difference_imageFilePath of the difference picture; empty when none was asked for.