python - 比较图像 Python PIL

标签 python python-imaging-library

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

最佳答案

要检查 jpg 文件是否完全相同,请使用 pillow 库:

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 - 比较图像 Python PIL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35176639/

相关文章:

python - 使用列表匹配包含整个单词的正则表达式

python - Django - 保存上传的图像

python - 查找相框的 Canvas 边界

python - 更改宽度/高度像素而不关心纵横比

python - 从 PyTorch 自定义数据集的 __getitem__ 中的巨大未压缩 tar 文件读取图像的最快方法

python - 使用重写的 __cmp__ 函数实现列表包装器

python - 如何在 Selenium 中等待 iframe 页面加载?

python - 无法在 Mac OS El Capitan 上安装 nltk

python - 没有名为 Pillow 的模块

python - 分区的 Observable 第二个流从未到达