Repository navigation
Conversation
Color mapped, truecolor and greyscale images, uncompressed and run length encoded, all four origins. TGAs have no magic number, ImageType recognizes them by a consistent header or the TGA 2.0 footer (no false positives over 2267 other image files). 16 bit files ignore the attribute bit like image-rs does, writers fill it inconsistently. encodeTGA() writes run length encoded 24 bit (opaque) or 32 bit files with the 2.0 footer. Matches Pillow on the Pillow and image-rs test files except for that bit, and also reads the image-rs files Pillow rejects. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ljnxm1Qjrocq1izGajLx8J
the release check doesn't remove it, it would end up in the release Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ljnxm1Qjrocq1izGajLx8J
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds Truevision TGA (Targa) decoding and encoding. TGA is still common for game textures, sprites and screenshots, and in 3D/VFX pipelines.
Decoding
ImageType.isTGA()/getType() === 'tga'recognize it by a consistent header or the TGA 2.0 footer. Over 2267 other image files (BMP, ICO, PSD, DDS, ...) it gave no false positives.Encoding
Image.encodeTGA()writes run length encoded files: 24 bit for opaque images, 32 bit otherwise. They have a top left origin and the TGA 2.0 footer, so they are easy to recognize.Verification
tests/tga.jsbuilds TGAs byte by byte: bottom left origin with an image ID, a color map with a first index offset and top right origin, run length encoded greyscale + alpha with packets crossing scan lines, the 16 bit attribute bit, encoding round trips and truncated data.Closes #21