from PIL import Image,ImageDraw,ImageFont
from pathlib import Path
root=Path(__file__).parent/'20261129T160940'
font=ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf',18)
for side in ['before','after']:
 lines=(root/(side+'.txt')).read_text().splitlines()
 # Keep the complete one-event command output and the other closing summaries.
 start=next(i for i,l in enumerate(lines) if '# 1 eligible' in l)
 end=next(i for i,l in enumerate(lines) if '# 0 eligible' in l)
 shown=[side.upper()+' | captured real CLI stdout',*lines[:2],'',*lines[start:end],'Plural checks:',*[l for l in lines if l.startswith('Done') and ', 1 superseded' not in l]]
 im=Image.new('RGB',(1380,len(shown)*28+40),'#111827'); d=ImageDraw.Draw(im)
 for i,line in enumerate(shown):d.text((22,20+i*28),line,font=font,fill='#fbbf24' if ', 1 superseded' in line else '#e5e7eb')
 im.save(root/(side+'.png'))
