- numerical difference is expected as positive or negative with decimal places
- compare the visual appearance of each image, not their binary contents
for example:
file1.png & file2.gif
diff 0.23
time elapsed 0.843
I have tried
from PIL import Image
from PIL import ImageChops
...
one = Image.open("file1.png")
two = Image.open("file2.gif")
diff = ImageChops.difference(one, two)
print(diff)
But ImageChops
does not work for comparing .gif and .png files. Error is
python3.8/site-packages/PIL/ImageChops.py", line 102, in difference
return image1._new(image1.im.chop_difference(image2.im))
ValueError: images do not match
Will imagemagick
or numpy
work? has to support .png, .gif (.jpg, .bmp are optional)
Try printing the modes of the images.
If those two modes != are not equal to each other, then it can bomb out as you are seeing.