# by movie on 2019/12/18from PILimportImage
from PILimportImageChops
path1= 'images/trumpA689.jpg'path2= 'images/trumpA748.jpg'diff_path= 'images/diff.bmp'imageA= Image.open('images/ImageA.bmp')
imageB= Image.open('images/ImageB.bmp')
dif=ImageChops.difference(imageB, imageA).getbbox()
print(dif)
# draw=ImageDraw.Draw(imageA)
#
# draw.rectangle(dif)
# imageA.show()
def compare(path1, path2, diffpath):
path1=Image.open(path1)
path2=Image.open(path2)
difference=ImageChops.difference(path1, path2)ifdifference.getbbox():
difference.save(diffpath)
compare(path1, path2, diff_path)