比较图像 Python PIL [英] Compare images Python PIL

查看:51
本文介绍了比较图像 Python PIL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何比较两张图片?我找到了 Python 的 PIL 库,但我不太明白它是如何工作的.

How can I compare two images? I found Python's PIL library, but I do not really understand how it works.

推荐答案

检查jpg文件是否完全一样使用枕头库:

To check does jpg files are exactly the same use pillow library:

from PIL import Image
from PIL import ImageChops

image_one = Image.open(path_one)
image_two = Image.open(path_two)

diff = ImageChops.difference(image_one, image_two)

if diff.getbbox():
    print("images are different")
else:
    print("images are the same")

这篇关于比较图像 Python PIL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆