from pathlib import Path
from PIL import Image, ImageChops
# Run inside the directory containing base/head-light/dark-a/b.png.
p = Path.cwd()
for side in ['base', 'head']:
    for theme in ['light', 'dark']:
        a = Image.open(p / f'{side}-{theme}-a.png').convert('RGB')
        b = Image.open(p / f'{side}-{theme}-b.png').convert('RGB')
        assert ImageChops.difference(a, b).getbbox() is None
        zoom = a.crop((944,2235,1036,2330)).resize((736,760), Image.Resampling.NEAREST)
        bg = (250,250,250) if theme == 'light' else (10,10,10)
        canvas = Image.new('RGB', (1080,1100), bg)
        canvas.paste(a.crop((0,2180,1080,2424)), (0,0))
        canvas.paste(zoom, (172,300))
        canvas.save(p / f'{side}-{theme}-evidence.png')
        print(side, theme, {name: a.getpixel(point) for name, point in {
            'background': (990,2310), 'shaft': (989,2290), 'tip': (989,2268)
        }.items()})
