-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Labels
Description
I think it would be useful to have a function to check if two images are the same. I don't mean with a perceptual hash like #3120, or with the existing Image.__eq__ method, but something to check if two images are visually similar. By that I mean the images are the same size and have the same color pixels, after taking into account the EXIF Orientation tag and the images possibly having different modes. Something like
def same_image(img_a,img_b):
img_a = ImageOps.exif_transpose(img_a)
img_b = ImageOps.exif_transpose(img_b)
if img_a.size != img_b.size:
return False
img_a = img_a.convert('RGBA')
img_b = img_b.convert('RGBA')
diff = ImageChops.difference(img_a,img_b)
return diff.getbbox() is None and diff.convert('RGB').getbbox() is Nonebut more efficient. And also it needs to handle images with multiple frames. Or maybe just throw an exception for those for now.
hytromo