Files
aigc-home/scripts/hel871/compare.py
T

29 lines
1.2 KiB
Python

"""Pair unmodified before/after UI captures; preserve originals and their hashes."""
import argparse
import hashlib
import json
from pathlib import Path
from PIL import Image, ImageDraw
p = argparse.ArgumentParser()
p.add_argument('--evidence', type=Path, required=True)
a = p.parse_args()
out = a.evidence/'comparison'
out.mkdir(exist_ok=True)
manifest = []
for theme in ['night', 'day', 'grade', 'bluehour']:
for width in [1440, 1366, 1280]:
for state in ['compact', 'manager']:
name = f'{theme}-{width}-{state}.png'
files = [a.evidence/phase/name for phase in ['before', 'after']]
images = [Image.open(f).convert('RGB') for f in files]
canvas = Image.new('RGB', (sum(im.width for im in images), max(im.height for im in images)+28), '#202020')
draw = ImageDraw.Draw(canvas)
x = 0
for label, im in zip(['BASE 344fede', 'HEL-871'], images):
draw.text((x+8, 8), label, fill='white')
canvas.paste(im, (x, 28)); x += im.width
canvas.save(out/name)
manifest.append({'file': name, 'sha256': [hashlib.sha256(f.read_bytes()).hexdigest() for f in files]})
(out/'manifest.json').write_text(json.dumps(manifest, indent=2))