Python比较图片的不同

时间:2020-10-22 19:26:30   收藏:0   阅读:18
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))

 

原文:https://www.cnblogs.com/ilazysoft/p/13860253.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!