ImageMagick has (quite) some nifty ways to compare images. For example this…
compare -metric AE <imgage1.png> <image2.png> null:
…will output the exact number of different pixels. So you can use the result to determine if the images are different enough – or identical, of course. You can also add a fuzz factor with -fuzz n%
that will help to ignore minor differences.
It offers many variations on this, e.g. limiting the diff to one color channel or looking for matching subimages, etc.