The basics
What is a TGA file?
TGA is the image format of the Targa boards, early graphics and video cards for PCs. AT&T's EPICenter group defined the format in 1984; the team became Truevision in 1987, and the specification's version 2.0 followed in 1989. The name Targa stands for Truevision Advanced Raster Graphics Adapter.
The format outlived the hardware because it's easy to write, keeps every pixel exactly, and can store an alpha channel. Video, animation and 3D software adopted it for rendered frames, and game developers for textures. Today you meet TGA files as:
- Game textures and source art, often as 32-bit images with alpha, imported into engines such as Unity and Unreal Engine or converted to DDS.
- Rendered image sequences from 3D and animation software, numbered frame by frame.
- Files from older software and archives of 1990s graphics work.
For anything shown on the web or sent to people, use PNG instead: also lossless, also with alpha, much smaller, and shown by every browser. Browsers don't display TGA.
Anatomy
What's inside a TGA file
A TGA file is an 18-byte header, an optional image ID, an optional colour map, the pixels and, in version 2, extension areas and a 26-byte footer. All numbers are little-endian. Below is every byte of a 69-byte file we made for this page with Pillow and checked in three other decoders: 4 × 2 pixels, run-length encoded, with red, red, red, green on top and blue, blue, white, white below. It isn't offered for download.
tiny.tga: 4 × 2 pixels, 24-bit, run-length encoded, 69 bytes
offset bytes part
000000 09 ID length: 9
000001 00 colour map type: none
000002 0A image type 10: RLE true-colour
000003 00 00 00 00 00 colour map spec: unused
000008 00 00 00 00 x and y origin: 0, 0
00000C 04 00 02 00 width 4, height 2
000010 18 24 bits per pixel
000011 00 descriptor: no alpha, bottom-left origin
000012 39 39 68 65 6C 70 65 72 73 image ID: "99helpers"
00001B 81 FF 00 00 run of 2: blue ← bottom row first
00001F 81 FF FF FF run of 2: white
000023 82 00 00 FF run of 3: red ← top row
000027 00 00 FF 00 1 raw pixel: green
00002B 00 00 00 00 footer: extension area offset (none)
00002F 00 00 00 00 developer area offset (none)
000033 54 52 55 45 56 49 53 49 4F 4E 2D 58 46 49 4C 45 2E 00
"TRUEVISION-XFILE." and a zero byte- 1
09ID length
The length of the free-form image ID that follows the header, 0 to 255 bytes. A TGA has no signature at the start, so the first byte is often
00. - 2
00Colour map type
0 for no colour map (palette), 1 if there is one.
- 3
0AImage type
10: true-colour, run-length encoded. The others: 1 colour-mapped, 2 true-colour, 3 greyscale, and 9, 10, 11 for their run-length encoded versions. 0 means no image data.
- 4
00 00 00 00 00Colour map specification
Where the palette starts, how many entries it has and how many bits each entry takes. Unused here.
- 5
00 00 00 00X and Y origin
Where the image would sit on a Targa display. Despite the name, these fields don't flip the image; the descriptor byte does.
- 6
04 00 02 00 18Size and depth
4 pixels wide, 2 high, 24 bits (
0x18) per pixel: 3 bytes each, in blue, green, red order. - 7
00Image descriptor
Bits 0 to 3 count the alpha (attribute) bits per pixel, 0 here. Bit 4 set means pixels run right to left, bit 5 set means rows run top to bottom. Both are clear: the first row in the file is the bottom row.
- 8
39 39 68 65 6C 70 65 72 73Image ID
Nine bytes of free text, here
99helpers. Programs use it for a name, a comment or nothing at all. - 9
81 FF 00 00A run-length packet
The top bit of
0x81is set, so it's a run; the low 7 bits plus 1 give the count, 2. The pixelFF 00 00(blue, green, red) is blue. So the bottom row starts with two blue pixels. - 10
00 00 FF 00A raw packet
The top bit is clear, so the next 0 + 1 = 1 pixel is stored as is:
00 FF 00, green. - 11
TRUEVISION-XFILE.The footer
The last 26 bytes: offsets of the extension and developer areas (0 means absent), then the signature
TRUEVISION-XFILE, a full stop and a zero byte. If the signature is there, it's a version 2 file.
Under the hood
How a TGA file is laid out
| Part | Size | What it holds |
|---|---|---|
| Header | 18 bytes | Image type, palette description, size, bit depth, descriptor |
| Image ID | 0 to 255 bytes | Free-form text or data |
| Colour map | Varies | The palette, for colour-mapped images |
| Image data | Varies | The pixels, raw or run-length encoded |
| Developer area | Optional (v2) | Data private to an application |
| Extension area | 495 bytes (v2) | Author, comments, date, software, gamma, alpha type, a thumbnail |
| Footer | 26 bytes (v2) | Offsets of the two areas and the signature |
True-colour pixels are stored as little-endian numbers, so the bytes come out as blue, green, red, and then alpha in 32-bit files. 16-bit pixels pack 5 bits each of red, green and blue plus 1 attribute bit. Greyscale images use 1 byte per pixel, and colour-mapped images 1 or 2 bytes per pixel, each an index into the palette.
No magic number at the start
Unlike PNG or BMP, a TGA file has no fixed signature in its first bytes. Programs recognise one by the extension, by sanity-checking the header (a known image type, a colour map type of 0 or 1, a plausible bit depth) or, for version 2 files, by the footer. That makes TGA easy to misidentify; validate the header before trusting an uploaded file.
Orientation
Why TGA images appear upside down
Bits 4 and 5 of the image descriptor (byte 17) say in which corner the pixel data starts. The default, with both bits clear, is the bottom-left corner: the first row in the file is the bottom of the picture, as in BMP. Many writers set bit 5 and store rows top to bottom instead.
| Bit 5 | Bit 4 | First pixel in the file |
|---|---|---|
| 0 | 0 | Bottom left (the default) |
| 1 | 0 | Top left |
| 0 | 1 | Bottom right |
| 1 | 1 | Top right |
A reader that ignores these bits shows half of all TGA files upside down. If a texture appears flipped in one program and not another, check byte 17: 0x20 (or 0x28 with 8 alpha bits) means top-left, 0x00 (or 0x08) bottom-left. Re-saving from GIMP, which offers a choice of origin when exporting, fixes it for picky readers.
Compression
Run-length encoding and alpha
Image types 9, 10 and 11 compress the pixels with run-length encoding. Each packet starts with a byte whose top bit says what follows and whose low 7 bits give a count from 1 to 128:
- Run packet (top bit set): one pixel value, repeated count times.
82 00 00 FFis three red pixels. - Raw packet (top bit clear): count pixel values, stored one after another.
- The specification says a run should never cross from one row to the next. Some writers ignore that, and strict readers may then fail; most readers accept it.
RLE works well on flat areas such as UI art, masks and cartoon textures, and hardly at all on photos and noisy renders, where most packets are raw and the file can even grow slightly. It's always lossless.
For alpha, a 32-bit TGA stores 8 alpha bits per pixel and should say so in the descriptor's low 4 bits (0x08). Version 2's extension area adds an attributes-type byte saying whether the alpha is meaningful and whether colours are premultiplied by it. Many writers leave the descriptor's alpha bits at 0 or skip the extension area, so programs guess, and the guesses differ (see the problems below).
Versions
Original TGA and TGA version 2
Version 2.0 (1989) kept the original layout, so old readers can still read new files and ignore what they don't understand. It added material after the image data, found through the footer:
- The footer: the last 26 bytes. Bytes 8 to 23 hold
TRUEVISION-XFILE, then a full stop and a zero byte. If they don't, the file is an original-format TGA, with just a header and image data. - The extension area: 495 bytes with an author name, comments, a date and time, a job name, the software and its version, a background colour, pixel aspect ratio, gamma, the alpha type and offsets to a colour-correction table, a thumbnail ("postage stamp") and a table of scan-line offsets.
- The developer area: tagged fields an application can use for its own data.
Many writers produce a footer with both offsets set to 0, as in our example: a version 2 file with no extra areas.
Comparison
TGA vs PNG, BMP and DDS
| TGA | PNG | BMP | DDS | |
|---|---|---|---|---|
| Compression | None or RLE (lossless) | Deflate (lossless) | Usually none | None or GPU block compression (lossy) |
| Alpha | Yes, 32-bit | Yes | 32-bit only, patchy support | Yes |
| Signature at the start | None | Yes | BM | DDS |
| Metadata | Image ID; extension area in v2 | Text, Exif | Very little | Format details only |
| Browsers | No | All | All | No |
| Typical use | Textures, render output | Web, screenshots, graphics | Simple programs and devices | Textures in games |
TGA's advantages today are that every graphics tool reads it and that decoding is trivial. PNG does the same job in less space for almost everything else.
Troubleshooting
Common TGA problems
- Upside down or mirrored. The origin bits weren't honoured (see above). Re-save with a top-left or bottom-left origin, or flip it in the engine's import settings.
- Transparent areas are black, white or solid. The alpha channel was ignored because the descriptor says 0 alpha bits, or the alpha type in the extension area says it isn't meaningful. Some programs also treat alpha as premultiplied when it isn't, giving dark fringes. Re-export as 32-bit with alpha.
- Red and blue are swapped. A reader took the BGR bytes for RGB.
- The file isn't recognised. With no signature at the start, a damaged or unusual header looks like any other data. Check the first 18 bytes against the table above.
- The image breaks up partway down. An RLE packet crosses a row boundary and the reader didn't expect it, or the file is truncated.
- The file is big. It's probably uncompressed. RLE helps on flat graphics; for anything else, PNG is much smaller.
How to
How to open, edit and convert a TGA file
- Open and edit: GIMP, Photoshop, Krita, Paint.NET, IrfanView and Affinity Photo. Visual Studio's Image Editor also opens TGA, with alpha.
- Save: GIMP's export dialog offers RLE compression and a choice of bottom-left or top-left origin. Photoshop offers 16, 24 or 32 bits and RLE.
- Convert on the command line:
magick texture.tga texture.pngwith ImageMagick, ormagick input.png -compress RLE output.tgafor an RLE TGA. - Inspect:
identify -verbose texture.tga(ImageMagick) oroiiotool --info -v texture.tga(OpenImageIO) shows the type, depth, compression and orientation.
A TGA contains only pixels and a little text, no scripts. The image ID and the extension area can hold an author name, comments, the software and a date; check them before publishing a file, and remember that pixels hidden by a zero alpha are still in the file.
Sample files
There are no sample TGA files on this page yet. To make one for testing, run magick input.png output.tga with ImageMagick, or export from GIMP.
Put it online
Have a TGA file? Give it a link.
Drop a TGA image on 99helpers and it gets its own web address. Browsers can't display TGA, so anyone who opens the link downloads the file, ready for an image editor or a game engine.
Questions
TGA files, frequently asked
What is a TGA file?
A Truevision Targa image: a simple raster format from 1984 that stores pixels uncompressed or with lossless run-length encoding, often with an alpha channel. It's still used for game textures and rendered frames.
How do I open a TGA file?
Use GIMP, Photoshop, Krita, Paint.NET or IrfanView. Browsers can't display TGA, and some built-in photo viewers can't either.
Why is my TGA upside down?
TGA rows are stored bottom-up by default, and bit 5 of the image descriptor switches to top-down. A program that ignores that bit shows the image upside down. Re-save the file or flip it on import.
Does TGA support transparency?
Yes. A 32-bit TGA has an 8-bit alpha channel. Programs differ in how carefully they read it, so if transparency disappears, re-export as 32-bit with alpha.
Is TGA lossless?
Yes. Pixels are stored raw or with run-length encoding, and both keep every pixel exactly.
TGA or PNG?
PNG for almost everything: also lossless with alpha, but much smaller and supported by browsers. Use TGA when a game engine, renderer or pipeline asks for it.
How do I convert TGA to PNG?
Open it in GIMP, Photoshop or Paint.NET and export as PNG, or run magick texture.tga texture.png. Nothing is lost, alpha included.
Related formats
Other file types explained
Keep going
Related
Sources
- Truevision TGA File Format Specification, version 2.0 (HTML copy)
- Library of Congress: TGA version 2.0 format description
- Library of Congress: TGA version 1.0 format description
- Wikipedia: Truevision TGA
- Microsoft Learn: Image Editor in Visual Studio
Last reviewed 27 October 2026.