画像ファイルをmd5のハッシュにして、比較するという簡単な方法です。
imgs
フォルダに入っている画像達で、hoge.jpg
と全く同じものが存在するか確認する方法です
import hashlib
from glob import glob
target = open("hoge.jpg", "rb").read()
target_md5 = hashlib.md5(target).hexdigest()
files = glob("imgs/*.jpg")
for file in files:
with open(file, 'rb') as image:
image_data = image.read()
image_md5 = hashlib.md5(image_data).hexdigest()
if md5 == target:
print("👀", end="")
結果
👀👀👀👀👀👀👀👀👀👀👀👀👀👀👀👀👀👀👀