Skip to content

End TGA run length packets with the row - #57

Merged
matmen merged 2 commits into
masterfrom
tga-rle-scanlines
Oct 15, 2026
Merged

matmen merged 2 commits into
masterfrom
tga-rle-scanlines

Conversation

@matmen

@matmen matmen commented Oct 15, 2026

Copy link
Copy Markdown
Collaborator

The TGA encoder wrote run length packets that span rows. TGA 2.0 forbids this, and some readers reject such files: Pillow fails with "buffer overrun", for example on a solid 20x10 image.

  • Packets now end with the row.
  • Output buffer: the worst case size now counts a packet header per 128 pixels of each row (it was per 128 pixels overall, which is too small for narrow images).
  • Tests: encoded files are walked packet by packet to check that no packet crosses a row. A new 1x300 image covers the worst case of one header per pixel.

TGA 2.0 requires packets not to span rows, and some readers reject such
files: Pillow fails with "buffer overrun" on e.g. a solid 20x10 image.
The worst case output size grows accordingly (a packet header per 128
pixels of a row).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ljnxm1Qjrocq1izGajLx8J
@matmen matmen self-assigned this Oct 15, 2026
@matmen matmen added the bug Something isn't working label Oct 15, 2026
@matmen matmen added this to the v3.2.0 milestone Oct 15, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ljnxm1Qjrocq1izGajLx8J
@matmen
matmen merged commit a0f1e0f into master Oct 15, 2026
13 checks passed
@matmen
matmen deleted the tga-rle-scanlines branch October 15, 2026 14:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant