rletopnm
Convert Utah Raster Toolkit image to PNM
TLDR
Convert an RLE image to a PNM file
Create a PGM image containing the RLE file's alpha channel
Operate in verbose mode and print the contents of the RLE header to stdout
SYNOPSIS
rletopnm [-verbose] [-alpha] [-weightmap] [-nointerleave] [-red] [-green] [-blue] [-bg-red=val] [-bg-green=val] [-bg-blue=val] [-xpos=val] [-ypos=val] [rlefile]
PARAMETERS
-verbose
Prints debugging information to standard error, which can be useful for understanding the conversion process or troubleshooting.
-alpha
Extracts the alpha (transparency) channel from the RLE file as a grayscale image. The output will be a PGM file representing the alpha mask.
-weightmap
Extracts a weight map from the RLE file, if present. The output will be a PGM file.
-nointerleave
Prevents interleaving of pixels during conversion. This option is typically used for specific technical scenarios and generally not needed for standard conversions.
-red
Extracts only the red color channel from the RLE image. The output will be a PGM file representing the red component of the image.
-green
Extracts only the green color channel from the RLE image. The output will be a PGM file representing the green component of the image.
-blue
Extracts only the blue color channel from the RLE image. The output will be a PGM file representing the blue component of the image.
-bg-red=val
Specifies the red component (0-255) of a background color to use for compositing if the RLE image has transparency. Requires -bg-green and -bg-blue to be specified as well.
-bg-green=val
Specifies the green component (0-255) of a background color to use for compositing if the RLE image has transparency. Requires -bg-red and -bg-blue to be specified as well.
-bg-blue=val
Specifies the blue component (0-255) of a background color to use for compositing if the RLE image has transparency. Requires -bg-red and -bg-green to be specified as well.
-xpos=val
Specifies the starting X coordinate (horizontal position) for extracting a sub-image from the RLE file.
-ypos=val
Specifies the starting Y coordinate (vertical position) for extracting a sub-image from the RLE file.
rlefile
The path to the input RLE image file. If not specified, rletopnm reads from standard input.
DESCRIPTION
The rletopnm command is a utility from the Netpbm project that converts image files in the Utah Run Length Encoded (RLE) format into the Netpbm Portable Anymap (PNM) format.
The RLE format is an older, platform-independent image format primarily associated with the Utah Raster Toolkit.
Netpbm's PNM format is a family of portable image formats including Portable Pixmap (PPM) for color images, Portable Graymap (PGM) for grayscale images, and Portable Bitmap (PBM) for black and white images.
By default, rletopnm attempts to produce a PPM file if the RLE input contains color information. If only a single channel is selected (e.g., red, green, or blue), or if the RLE file has no color information, it generates a PGM file. If no channels are explicitly chosen and the RLE file lacks color data, or if the -alpha option is used, a PBM file might be produced.
Input RLE data can come from a specified file or, by default, from standard input, and the converted PNM output is written to standard output.
CAVEATS
The RLE format is relatively old and less commonly encountered today compared to modern image formats like JPEG, PNG, or GIF.
While rletopnm handles common RLE variations, complex or non-standard RLE files might not be fully supported.
When compositing with background colors using the -bg-red/green/blue options, ensure the input RLE file actually contains transparency information for the effect to be meaningful.
Output is always to standard output, so redirection (e.g., `rletopnm image.rle > image.pnm`) is necessary to save the result to a file.
INPUT AND OUTPUT
rletopnm accepts an RLE file as input, either specified as an argument (rlefile) or read from standard input if no file is provided. The converted image is always written to standard output in one of the Netpbm PNM formats (PPM, PGM, or PBM) depending on the input RLE's characteristics and the command-line options used. This means you must redirect the output to a file, for example: rletopnm input.rle > output.pnm
CONVERSION LOGIC
The command attempts to produce the 'richest' possible PNM format. If the RLE file has color, it outputs PPM. If you select a single color channel (e.g., -red), or if the RLE file is grayscale, it outputs PGM. If the RLE file is monochrome or the -alpha option is used (and the RLE has no color data), it outputs PBM.
HISTORY
rletopnm is an integral part of the Netpbm package, a widely-used toolkit for image manipulation on Unix-like operating systems. Netpbm originated from the pbmplus package, first released in 1991 by Jef Poskanzer, which itself built upon earlier individual image format converters.
The toolkit was designed to provide a modular and extensible way to convert between various image formats, processing images through a common 'portable anymap' (PNM) intermediate format. rletopnm specifically addresses the need to convert images from the older Utah RLE format, ensuring interoperability with other Netpbm tools and more modern image formats.