#!/usr/bin/env python3
"""Accept two unmodified Browser-panel screenshots only when pixel identical."""
import json, pathlib, shutil, sys
from PIL import Image, ImageChops
a,b,out=map(pathlib.Path,sys.argv[1:])
ia,ib=Image.open(a).convert('RGB'),Image.open(b).convert('RGB')
same=ia.size==ib.size and ImageChops.difference(ia,ib).getbbox() is None
if same: shutil.copyfile(b,out)
print(json.dumps({'identical':same,'size':ib.size,'output':str(out) if same else None}))
