from PIL import Image, ImageDraw, ImageFont
import pathlib, textwrap, sys
folder=pathlib.Path(sys.argv[1]); title=sys.argv[2]
font=ImageFont.truetype('/usr/share/fonts/truetype/dejavu/DejaVuSansMono.ttf',16)
lines=[title,'Linux CLI | built bundle | isolated synthetic settings','Captured stdout/stderr (wrapped at 110 columns)','']
for line in (folder/'transcript.txt').read_text().splitlines():
    lines.extend(textwrap.wrap(line,110,replace_whitespace=False,drop_whitespace=False) or [''])
image=Image.new('RGB',(1120,40+24*len(lines)), '#111827'); draw=ImageDraw.Draw(image)
for i,line in enumerate(lines):
    draw.text((24,20+i*24), line, font=font, fill=('#67e8f9' if i<3 or line.startswith('$') else '#e5e7eb'))
image.save(folder/'capture.png')
