Python比較圖片的不同

from PIL import ImageChops, Image

image_one = Image.open('pic_1.png')
image_two = Image.open('pic_1_same.png')
diff = ImageChops.difference(image_one, image_two)

try:
    if diff.getbbox() is None:
        print("【+】We are the same!")
    else:
        diff.save('diff.png')
except ValueError as e:
    text = ("We are different!")
    print("【{0}】{1}".format(e, text))

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章