Someone drops a .tga file on you and your usual image tools shrug. tgatoppm turns it into a PPM you can actually work with, checks the header when something looks off, and can pull the transparency channel out as its own PGM. Allow about ten minutes if you already know the input path. Examples use the Netpbm 11.5.2 command installed on this machine.
You need a readable .tga file and the netpbm package. Conversion needs no elevated privileges; do not reach for sudo just because the file happens to be an image. If the source or destination sits in a protected directory, solve that file access separately and keep the conversion itself unprivileged.
Confirm the binary and library version before trusting a script against it. Both checks are read-only:
$ command -v tgatoppm
/usr/bin/tgatoppm
$ tgatoppm --version
tgatoppm: Using libnetpbm from Netpbm Version: Netpbm 11.5.2
The version output also carries build information. This local manual page is dated 2 April 2000, while the installed library is Netpbm 11.5.2; everything below matches the installed program and its documented interface, so check again if you move the script to a different Netpbm release.
Checkpoint: the command is present and the input file is readable:
$ test -r /path/to/input.tga && echo "input is readable"
input is readable
tgatoppm takes one TGA filename and writes the PPM image to standard output. Redirect it somewhere disposable:
$ tgatoppm /path/to/input.tga > /path/to/output.ppm
Expect no progress message: the image itself is the standard output. Verify the result with a Netpbm inspection tool:
$ pnmfile /path/to/output.ppm
/path/to/output.ppm: PPM raw, 1920 by 1080 maxval 255
Your dimensions will differ. What actually matters is a successful exit status, a non-empty destination, and a sane PPM description. You can also peek at the magic number without dumping raw pixels into your terminal:
$ head -c 2 /path/to/output.ppm
P6
PPM output is often raw binary, so do not open the whole file in a terminal or text editor. Keep the original TGA around until the PPM has passed whatever viewer or later tool you actually intend to use.
Warning: shell redirection with > truncates the destination before tgatoppm even starts running, which is destructive if that name already held something useful. Convert to a temporary name in the same directory first, and only replace the real destination after inspection:
$ tgatoppm /path/to/input.tga > /path/to/output.ppm.new
$ pnmfile /path/to/output.ppm.new
/path/to/output.ppm.new: PPM raw, 1920 by 1080 maxval 255
$ mv /path/to/output.ppm.new /path/to/output.ppm
mv changes the directory entry and can replace an existing file, so only run it once the new image is genuinely the one you want. If conversion fails, remove the incomplete output.ppm.new after confirming it is your temporary file. The old output stays in place until that final move.
Use --headerdump to see what the converter actually read. Header details go to standard error while the PPM still lands on standard output:
$ tgatoppm --headerdump /path/to/input.tga > /path/to/output.ppm 2> /tmp/tgatoppm-header.txt
$ sed -n '1,3p' /tmp/tgatoppm-header.txt
tgatoppm: IdLength = 6
tgatoppm: CoMapType = 1
tgatoppm: ImgType = 9 (TGA_RLEMap)
Field values depend on the file. This can reveal whether a colour map, image type, origin or other header field was present, but it is diagnostic text, not a substitute for checking the converted image. The temporary log under /tmp is safe to delete after review: it holds header metadata, not PPM pixels.
tgatoppm throws away an input transparency channel by default. Add --alphaout= with a filename to write it out as a PGM image instead:
$ tgatoppm --alphaout=/path/to/alpha.pgm /path/to/input.tga > /path/to/output.ppm
$ pnmfile /path/to/alpha.pgm
/path/to/alpha.pgm: PGM raw, 1920 by 1080 maxval 255
If the TGA has no transparency channel at all, the manual says the alpha file comes out all zero. The PGM is a separate greyscale image; keep it next to the PPM if a compositor further down the pipeline needs both. pamcomp is the Netpbm tool the manual names for using transparency output, though the exact composition command depends on your foreground and background images.
There is also a special output name, a single hyphen:
$ tgatoppm --alphaout=- /path/to/input.tga > /path/to/alpha.pgm
In this mode the transparency data goes to standard output and the image itself is discarded. Use it only when the alpha channel is all you actually want; do not expect a PPM as well, and never combine it with a normal PPM destination unless you have deliberately chosen which stream to keep.
If the command cannot open the input, check the exact path and permissions without changing them:
$ ls -l /path/to/input.tga
$ test -r /path/to/input.tga && echo readable
If the output file is empty or incomplete, check the exit status immediately after running the command and read the terminal error. Re-run to a fresh temporary name rather than overwriting a known-good PPM. A successful conversion only proves the program finished; it says nothing about whether the orientation, colours or transparency handling are what you actually need.
If a file has transparency but you did not request an alpha file, run the conversion again with --alphaout=/path/to/alpha.pgm. For quiet scripted runs, use the common Netpbm -quiet option that libnetpbm programs share, but keep checking the exit status regardless: normal-looking diagnostic text is not proof of success.
tgatoppm is installed and its local Netpbm version is known.pnmfile.--alphaout=- outputs alpha and drops the image.