.TGA Truevision TGA
.tga

Truevision TGA

TGA (Targa) is a raster image format created by Truevision in 1984, supporting up to 32-bit color with an 8-bit alpha channel. It remains widely used in game development, 3D rendering, and video post-production for its simplicity and lossless alpha transparency.

Image structure
Header signature
Meta dimensions · color
Pixels image data
Truevision32-bit BGRAAlpha ChannelRLE Optional1984
By FileDex
Not convertible

Truevision TGA lacks browser codec support and modern WASM image libraries prioritize web-native formats.

Looking to convert? Try a related format:

Common questions

How do I open and inspect a TGA file?

Use IrfanView or XnView for quick viewing on Windows. On Linux/macOS, GIMP opens TGA files natively. For CLI inspection without rendering, use exiftool -ImageWidth -ImageHeight -BitsPerPixel input.tga to read header fields.

Why does my TGA image appear upside down?

TGA supports both bottom-up (default, legacy) and top-down scan order, controlled by bit 5 of the image descriptor byte at offset 0x11. Some viewers ignore this flag. Re-save the file with the correct orientation in GIMP or ImageMagick: magick input.tga -flip output.tga.

Should I use TGA or PNG for game textures?

Use PNG for new projects. PNG offers lossless compression (30-60% smaller files), identical quality, full alpha support, and universal tool compatibility. TGA remains in use primarily for legacy pipelines and some texture tools that expect uncompressed pixel data.

Why does TGA have no magic bytes?

TGA was designed in 1984 before file signatures became standard practice. The 18-byte header starts directly with data fields (ID length, color map type, image type). TGA v2.0 (1991) added the optional TRUEVISION-XFILE footer at the end of the file, but it is not mandatory.

What makes .TGA special

What is a TGA file?

TGA (Targa) is a raster graphics format created by Truevision in 1984. It supports up to 32-bit color with an 8-bit alpha channel for transparency. TGA became a standard in the video game and video editing industries due to its simplicity, alpha support, and minimal compression overhead.

Continue reading — full technical deep dive

How to open TGA files

  • Adobe Photoshop (Windows, macOS) — Full support
  • GIMP (Windows, macOS, Linux) — Free, full support
  • IrfanView (Windows) — Lightweight viewer
  • XnView (Windows, macOS, Linux) — Free viewer

Technical specifications

Property Value
Color Depth 8, 16, 24, 32 bit
Alpha Channel 8-bit (in 32-bit mode)
Compression None or RLE
Max Resolution 65,535 x 65,535 px
Orientation Bottom-up or top-down

Common use cases

  • Game development: Texture files for 3D models and sprites.
  • Video editing: Frame sequences with alpha channels.
  • 3D rendering: Texture maps for 3D applications.
  • Legacy workflows: Older animation and VFX pipelines.

.TGA compared to alternatives

.TGA compared to alternative formats
Formats Criteria Winner
.TGA vs .PNG
File size and compatibility
PNG uses lossless compression (Deflate) producing files 30-60% smaller than uncompressed TGA while preserving identical quality and alpha. PNG is natively supported by all browsers and image tools; TGA requires specialized software.
PNG wins
.TGA vs .BMP
Alpha channel support
TGA natively supports 8-bit alpha in 32-bit mode, which is why game developers preferred it over BMP. BMP added alpha support later in v4/v5 headers, but adoption was inconsistent across tools.
TGA wins
.TGA vs .EXR
HDR and modern pipeline support
EXR supports 16-bit and 32-bit floating-point channels for HDR rendering, multi-layer compositing, and deep image data. TGA is limited to 8 bits per channel, making it unsuitable for modern VFX and HDR pipelines.
EXR wins

Technical reference

MIME Type
image/x-tga
Developer
Truevision (now Avid)
Year Introduced
1984
Open Standard
Yes

Binary Structure

TGA files have an 18-byte fixed header with no mandatory magic bytes at offset 0 — identification relies on header field validation. Byte 0 is the ID length (0-255 bytes of optional image identification following the header). Byte 1 is the color map type: 0 = no palette, 1 = palette present. Byte 2 is the image type: 0 = no data, 1 = uncompressed color-mapped, 2 = uncompressed true-color, 3 = uncompressed grayscale, 9 = RLE color-mapped, 10 = RLE true-color, 11 = RLE grayscale. Bytes 3-7 are the color map specification: 2-byte first entry index, 2-byte color map length, 1-byte bits per entry (15, 16, 24, or 32). Bytes 8-9 are the X origin, bytes 10-11 are the Y origin (both 16-bit little-endian). Bytes 12-13 are the image width, bytes 14-15 are the image height (both 16-bit LE, max 65535). Byte 16 is the pixel depth (8, 16, 24, or 32 bits). Byte 17 is the image descriptor: bits 0-3 specify the number of alpha/attribute bits, bit 4 is the left-to-right flag, and bit 5 is the top-to-bottom flag (0 = bottom-up, the default and legacy convention; 1 = top-down). Pixel data follows in BGRA order (not RGBA). For RLE types, each run begins with a packet header byte: bit 7 set = run-length packet (repeat next pixel N+1 times), bit 7 clear = raw packet (N+1 literal pixels follow). TGA v2.0 adds an optional footer at the last 26 bytes: 4-byte extension area offset, 4-byte developer directory offset, and the 18-byte signature 'TRUEVISION-XFILE.\0'. The extension area (if present) contains author, comments, date, job time, software ID, gamma, and color correction data.

OffsetLengthFieldExampleDescription
0x00 1 byte ID length 00 Length of the optional image identification field (0 = no ID). This field immediately follows the 18-byte header.
0x01 1 byte Color map type 00 0 = no color map (true-color/grayscale), 1 = color map present (paletted image).
0x02 1 byte Image type 02 2 = uncompressed true-color, 10 = RLE true-color, 3 = grayscale, 9 = RLE color-mapped.
0x03 5 bytes Color map specification 00 00 00 00 00 First entry index (2B), length (2B), bits per entry (1B). All zeros when no palette.
0x08 4 bytes X/Y origin 00 00 00 00 Image origin coordinates (little-endian). Usually (0,0). Y origin meaning depends on scan direction.
0x0C 4 bytes Width / Height 00 04 00 03 Image dimensions in pixels (16-bit LE each). Example: 1024 x 768.
0x10 1 byte Pixel depth 20 Bits per pixel: 0x08=8-bit, 0x10=16-bit, 0x18=24-bit, 0x20=32-bit (with alpha).
0x11 1 byte Image descriptor 28 Bits 0-3: alpha bits (8 for 32bpp). Bit 4: L-R order. Bit 5: top-down (1) or bottom-up (0).
1984Truevision introduces TGA with the TARGA (Truevision Advanced Raster Graphics Adapter) video board1989TGA becomes the standard texture format for early 3D games and rendering software1991TGA v2.0 specification adds the TRUEVISION-XFILE footer, extension area, and developer area2000sGame engines (Unreal, Source) adopt TGA as a primary texture import format for its alpha channel support2010sTGA use declines in new projects as PNG and EXR offer better compression and HDR support respectively
Convert TGA to PNG preserving alpha imagemagick
magick input.tga output.png

Converts TGA to PNG with lossless compression. Alpha channel is preserved automatically in 32-bit TGA files. ImageMagick handles both bottom-up and top-down TGA scan orders.

Batch convert TGA folder to JPG imagemagick
magick mogrify -format jpg -quality 92 *.tga

Converts all TGA files in the current directory to JPEG at 92% quality. The mogrify command processes files in-place. Alpha channel is discarded since JPEG does not support transparency.

Inspect TGA header fields exiftool
exiftool -ImageWidth -ImageHeight -BitsPerPixel -ImageType input.tga

Reads TGA header fields without loading pixel data. Shows dimensions, bit depth, and image type (true-color, grayscale, color-mapped). Useful for quick format verification.

TGA PNG transcode lossless PNG preserves TGA's full color depth and alpha channel with lossless compression, producing smaller files. PNG is universally supported by browsers, image editors, and game engines, making it the ideal lossless replacement for TGA.
TGA JPG transcode lossy JPEG produces much smaller files for photographic TGA content where alpha transparency is not needed. Useful for web display, thumbnails, and distribution where file size matters more than lossless quality.
LOW

Attack Vectors

  • Malformed header fields (pixel depth, dimensions) can trigger integer overflows in decoders that allocate width * height * bpp bytes without validation
  • RLE packet length exceeding image bounds causes buffer overreads in parsers without bounds checking

Mitigation: FileDex does not open, execute, or parse TGA files. Reference page only.

Open-source image toolkit with full TGA read/write support including RLE and alpha channels
GIMP tool
Free image editor with TGA import/export. Handles 32-bit BGRA and RLE compression.
stb_image library
Single-header C library for loading TGA, PNG, JPG. Widely used in game engines and tools.
FreeImage library
Multi-format image library supporting TGA v1/v2 with RLE, used in 3D and game toolchains