Why won't my TGA file open?
TGA (Truevision TGA, also called Targa) dates from 1984 and is still common for game textures: Unity and Unreal Engine list it as a texture format, and Minecraft Bedrock asks for TGA with an alpha channel for textures with transparent or glowing parts. But Chrome, Edge and Firefox have no TGA decoder, Safari does not show TGA in web pages, and Windows' built-in imaging component has no TGA codec. So this page reads the file itself, with its own decoder written from the Truevision TGA 2.0 specification, and writes a PNG or JPG on your device.
What kinds of TGA does it open?
All the image types in the TGA 2.0 specification, uncompressed or run-length encoded (RLE):
| Image type | What it holds |
|---|---|
| 1 | Colour-mapped |
| 2 | True colour |
| 3 | Greyscale |
| 9 | Colour-mapped, RLE |
| 10 | True colour, RLE |
| 11 | Greyscale, RLE |
True colour at 15, 16, 24 or 32 bits a pixel; greyscale at 8 bits, or 16 with alpha; colour maps with 15-, 16-, 24- or 32-bit colours. Each file in the list shows its type and bit depth, and after converting, where its rows start and whether its alpha channel was used. Files up to 300 MB and 67,108,864 pixels (8,192 ร 8,192) open. Files using the Huffman or quadtree compression of the version 1 guide (types 32 and 33) do not; the 2.0 specification no longer lists them.
Why does my TGA look upside down?
Two bits in the header say which corner the first stored pixel belongs to, and the default (both bits 0) is the bottom-left, so a file stored bottom row first is normal TGA; others set the bits for top-down. Programs that ignore those bits show such pictures flipped, a complaint that comes up on game-development and video forums. In our test files, Pillow wrote bottom-up rows and ImageMagick and FFmpeg top-down. This page follows the bits, including the rare right-to-left order, and the file list tells you how each file was stored.
Why is the background black, white or see-through?
- 24-bit TGA has no transparency. Only 32-bit files (or 16-bit colour with an attribute bit, 16-bit greyscale, or a colour map with alpha) can have it, so a 24-bit file always converts opaque.
- An empty alpha channel. A 32-bit file can have every alpha byte at 0. Read literally, the picture would be invisible, so a file whose alpha is all 0 converts as opaque, and the list says so.
- The file says what its alpha means. TGA 2.0 files can carry an extension area whose Attributes Type field says there is no alpha (0), undefined data in the alpha bits (1, 2), real alpha (3) or premultiplied alpha (4). This page uses the alpha only for 3 and 4, and converts premultiplied colours back to the straight colours PNG needs. (The specification's own text calls the premultiplied value 3 in one paragraph; its table, which we follow, says 4.)
- 16-bit transparency is read differently by different programs. GIMP treats a set attribute bit as opaque, Pillow as transparent, and stb_image ignores it. This page follows GIMP, and only when the header says the file has exactly one attribute bit or its extension area says it has alpha.
- Hidden colours. Fully transparent pixels still store a colour, for example black or a flat blue. PNG keeps them transparent; for JPG, which has no transparency, they are laid over the background colour you choose.
Is TGA to PNG lossless?
Yes. The PNG holds every pixel and the alpha channel exactly as decoded. In current browsers it is written by this page's own encoder, so partly transparent pixels are not rounded the way a browser canvas rounds them (a browser without the Compression Streams feature falls back to the canvas). We checked our decoder on 20 test files, 19 written by three different programs (ImageMagick, FFmpeg and Pillow) and one found in a desktop app's cache, covering every image type, 8- to 32-bit depths and both row orders. Our pixels matched ImageMagick's exactly on 18 of them and Pillow's on 19. The exceptions: ImageMagick misread Pillow's two 16-bit greyscale-with-alpha files (no alpha, wrong greys), where we match Pillow; and on one 16-bit colour file Pillow turns 5-bit colour into 8 bits with different rounding, up to 1 level apart, where we match ImageMagick. All 20 PNGs this page wrote in Chrome decoded to the same pixels in both ImageMagick and Pillow; the batch took about 3.3 seconds. JPG loses a little detail by design.
Is PNG smaller than TGA?
Usually much smaller. TGA's only compression is RLE, which shrinks flat areas but barely touches photos and noisy textures; PNG's compression finds far more. From our test files:
| Picture | TGA, uncompressed | TGA, RLE | PNG from this page |
|---|---|---|---|
| Photo, 1,600 ร 1,199, 24-bit | 5,755,244 bytes | 5,450,360 bytes (5% smaller) | 3,367,213 bytes (41% smaller) |
| Logo with transparency, 800 ร 322, 32-bit | 1,030,418 bytes | 154,563 bytes (85% smaller) | 38,098 bytes (96% smaller) |
| The photo in greyscale, 8-bit | 1,918,418 bytes | 1,857,572 bytes | 1,247,875 bytes |
The PNG keeps greyscale files in grey and drops the alpha channel when every pixel is opaque, so it stays small. One case grows: a 256-colour (colour-mapped) photo, 1,919,212 bytes as TGA, became 3,243,531 bytes as PNG, because the PNG is written in full colour. An uncompressed TGA's size is 18 header bytes plus width ร height ร bytes per pixel, plus any image ID, colour map and the optional 26-byte version 2 footer (which the photo's file above has): a 2,048 ร 2,048 texture at 32 bits is at least 16,777,234 bytes.
Other ways to open a TGA file
- GIMP opens and exports TGA, with options for RLE and the row order.
- Blender reads and writes Targa files with alpha.
- ImageMagick:
magick in.tga out.png, ormagick mogrify -format png *.tgafor a folder. - Any phone or computer: this page runs in a web browser, so you need no app. To shrink the PNGs further, use the image compressor.