Skip to content

render_terminal_png.py silently clips lines longer than 92 characters instead of wrapping them #443

Description

@yakew7

Where: scripts/render_terminal_png.py - MAX_WIDTH_CHARS (line 24) caps the canvas-width calculation (line 37: min(max_line_len, MAX_WIDTH_CHARS)), but is never applied to the actual draw.text(...) call (lines 43-45), which draws the full, un-wrapped line regardless of length.

The gap: any captured line longer than 92 characters gets drawn at its full pixel width onto a canvas sized only for 92 characters - the excess is clipped off the right edge with no wrapping, truncation mark, or warning.

Repro:

>>> import sys; sys.path.insert(0, 'scripts')
>>> import render_terminal_png as script
>>> text = "ok\n" + "X" * 150
>>> script.render(text, "/tmp/test_render.png")
>>> from PIL import Image
>>> Image.open("/tmp/test_render.png").size
(864, 74)

864px is exactly the canvas width for the 92-character cap; the actual 150-character line needs roughly 1350px to draw in full, so the last ~54 characters are drawn off-canvas and clipped.

Why it matters: this script renders real captured terminal output for fair.png/unfair.png, the before/after screenshots README.md documents for every audit - any terminal line wider than 92 characters (easy to hit with a wide table or a long path) is silently mutilated in the committed, published image with no error anywhere in the pipeline.

Suggested fix: either wrap lines exceeding MAX_WIDTH_CHARS (e.g. via textwrap) before drawing, or size the canvas to the actual longest line's real pixel width instead of a capped character count.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions