import base64
from io import BytesIO
from PIL import Image, ImageChops
a_base_64 = 'iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DA' \
'cdvqGQAAAAWSURBVBhXY3BwcGBgYGD8//8/AwMDABgGA7/DZDVsAAAAAElFTkSuQmCC'
b_base_64 = 'iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DA' \
'cdvqGQAAAAVSURBVBhXY/z//z8DAwMTEDMwMAAAJAYDAbrboo8AAAAASUVORK5CYII='
a = Image.open(BytesIO(base64.b64decode(a_base_64)))
b = Image.open(BytesIO(base64.b64decode(b_base_64)))
diff = ImageChops.difference(a, b).convert('L')
print(sum(diff.point(bool).getdata()))
OUT
2
Process finished with exit code 0