from PIL import Image, ImageDraw, ImageFont
from pathlib import Path
root=Path(__file__).parent
font=ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf',18)
for side in ['before','after']:
    text=(root/(side+'.txt')).read_text()
    lines=text.splitlines()
    im=Image.new('RGB',(1080,70+len(lines)*27),'#111827')
    d=ImageDraw.Draw(im)
    d.text((28,20),side.upper()+' — captured real CLI stdout',font=font,fill='#93c5fd')
    for i,line in enumerate(lines):
        d.text((28,65+i*27),line,font=font,fill='#86efac' if 'trace:' in line else '#e5e7eb')
    im.save(root/(side+'.png'))
