ppmtotga
Convert PPM image files to TGA format
TLDR
View documentation for the current command
SYNOPSIS
ppmtotga [-16 | -24 | -32] [-rle] [-mono | -rgb] [ppmfile]
PARAMETERS
-16
Outputs the TGA image in 16-bit format (RGB 5:5:5 or 5:6:5, depending on the colors). If the image has an alpha channel, it is ignored.
-24
Outputs the TGA image in 24-bit format (RGB 8:8:8). Alpha channel information, if present, is discarded.
-32
Outputs the TGA image in 32-bit format (RGBA 8:8:8:8). This option includes an alpha channel in the output TGA if the input PPM contains transparency information (e.g., from a PAM image).
-rle
Encodes the output TGA image using Run-Length Encoding (RLE) compression. By default, the output TGA is uncompressed.
-mono
Forces the output TGA image to be monochrome (8-bit grayscale). If the input PPM is color, it will be dithered down to grayscale.
-rgb
Forces the output TGA image to be 24-bit RGB, even if the input PPM is grayscale. This ensures a full-color TGA file.
ppmfile
Specifies the input PPM image file. If this argument is omitted, ppmtotga reads the PPM image data from standard input.
DESCRIPTION
ppmtotga is a specialized utility within the Netpbm toolkit, designed for converting images from the Portable Pixmap (PPM) format to the Truevision Targa (TGA) format. PPM is a widely used, simple, and uncompressed image format favored as an intermediate format in Netpbm pipelines due to its direct representation of pixels. TGA is a popular raster graphics file format, particularly noted for its historical use in PC gaming and its support for alpha channels.
By default, ppmtotga reads a PPM image from standard input and outputs the resulting TGA image to standard output, making it highly suitable for shell scripting and piping operations. It offers flexibility by supporting various TGA subformats, including uncompressed or run-length encoded (RLE), and different bit depths such as 16-bit, 24-bit, and 32-bit (which includes an alpha channel). This tool is crucial for interoperability, allowing users to transform images between Netpbm's native formats and applications or systems that require TGA files.
CAVEATS
When no bit depth option (-16, -24, -32) is specified, ppmtotga attempts to choose the smallest TGA type capable of representing the input PPM's colors. For proper alpha channel handling with -32, the input PPM must conform to Netpbm's internal representation for transparency, often created by tools like pnmremap from a PAM image.
DEFAULT BEHAVIOR
If no specific options for bit depth or compression are provided, ppmtotga analyzes the input PPM to determine the most suitable TGA format (e.g., 16-bit, 24-bit, or 32-bit with alpha if present) and outputs an uncompressed TGA file. It seamlessly operates as a filter, reading from standard input and writing to standard output by default, which is characteristic of most Netpbm tools.
ALPHA CHANNEL SUPPORT
While ppmtotga -32 generates a 32-bit TGA file with an alpha channel, it's crucial that the input PPM carries the alpha information in a format ppmtotga can interpret. typically, this means the PPM was derived from a Netpbm PAM (Portable Arbitrary Map) image that explicitly included a transparency plane, processed perhaps by pnmremap to create the specific PPM structure ppmtotga expects for alpha data.
HISTORY
ppmtotga is a long-standing component of the Netpbm project, a comprehensive suite of graphics manipulation utilities for Unix-like systems. Its development has paralleled the evolution of Netpbm itself, maintaining its role as a stable and reliable tool for converting between the flexible PPM format and the TGA standard.