from PIL import Image, ImageChops
image1 = Image.open('a.png')
image2 = Image.open('b.png')
# モードが一致していないとValueError: images do not matchと言われる
if image1.mode == image2.mode:
diff = ImageChops.difference(image1, image2)
モードが異なる画像でImageChops.differeceを呼ぶと、ValueErrorが出る。
モードの確認をしましょう
Python3 Pillowで画像の差を求める時はモードの確認を


コメント