from PIL import Image,ImageDraw,ImageFont
from pathlib import Path
import textwrap
root=Path(__file__).parent/'20261127-100644'
font=ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf',18)
for side in ['before','after']:
 text=(root/side/'transcript.txt').read_text()
 lines=[side.upper()+' — captured CLI stdout/stderr (wrapped for display)','']
 for l in text.splitlines(): lines.extend(textwrap.wrap(l,112,replace_whitespace=False,drop_whitespace=False) or [''])
 img=Image.new('RGB',(1280,len(lines)*25+48),'#101419'); draw=ImageDraw.Draw(img)
 for i,l in enumerate(lines): draw.text((24,24+25*i),l,font=font,fill=('#7dd3fc' if l.startswith('$') else '#e5e7eb'))
 img.save(root/side/(side+'.png'))
