I'm using the compare
command from imagemagick in my scripts to find out whether two images are identical or not. I recently found out that the order of the arguments to compare
matters. Here are two images, one with transparent pixels and one without:
When I run compare -metric AE img1.png img2.png null:
on these two files I will either get 1318
with an exit status of 1 or 0
with an exit status of 0. Is there a way to make the convert tool behave in a way such that the order I pass images to it does not matter? Or do I have to run convert
twice and only let two images be equal if they compare as equal if both orders succeed? That sounds very wasteful as I'm doing a lot of comparisons including of much larger images.
This behaviour is not documented, is it? Is it intentional?
It likely has to do with one image having transparency and the other not in Imagemagick compare.
Try adding -alpha off (so you do not include the alpha channel in one and not the other) and you will get 0 for both.
Or add -alpha set (so you include the alpha channel in both, but one image will be opaque alpha) and you will get 1318 for both.