def near_identical(im1, im2): """ Check if two images are identical (or near enough). """ diff = ImageChops.difference(im1, im2).histogram() for color in diff[2:]: if color: return False return True