rasttopnm
Convert Sun rasterfile to portable anymap
TLDR
Convert a RAST image to a PNM file
Use the color map indices in the raster if they are color values
SYNOPSIS
rasttopnm [-alphaout=alpha-filename] [-alphainvert] [-force] [-assume24bit] [-cmapout=cmap-filename] [-verbose] [rasterfile]
PARAMETERS
-alphaout=alpha-filename
Extracts the alpha (transparency) channel into a separate PGM file named alpha-filename. If omitted, the alpha channel is discarded.
-alphainvert
Inverts the values of the alpha channel before outputting it via -alphaout. Useful if the input alpha is conventionally inverted.
-force
Attempts to convert the file even if its header appears suspicious or malformed. Use with caution as it might result in corrupted output.
-assume24bit
Treats input files that rasttopnm cannot otherwise classify as 24-bit color rasterfiles. This option is a workaround for certain non-standard or malformed raster files.
-cmapout=cmap-filename
Extracts the colormap of colormapped rasterfiles into a separate PPM file named cmap-filename.
-verbose
Enables verbose output during the conversion process, printing diagnostic messages to standard error.
rasterfile
The path to the input Sun rasterfile. If not specified, rasttopnm reads from standard input.
DESCRIPTION
rasttopnm is a utility from the Netpbm project that converts a Sun rasterfile (also known as SunOS rasterfile or Sun icon format) into a portable anymap (PBM, PGM, or PPM) image. It supports various Sun rasterfile formats, including both old and new versions, those with colormaps, and run-length encoded data.
The output format (PBM for black & white, PGM for grayscale, PPM for color) is automatically determined by the input rasterfile's characteristics. This tool is essential for interoperability between legacy Sun image formats and modern image processing tools that support the Netpbm formats.
CAVEATS
rasttopnm is specifically designed for Sun raster files and will not work for other image formats. While the -force option can assist with slightly malformed headers, severely corrupted files might still fail or produce unusable output. Alpha channel information is discarded by default unless explicitly extracted using the -alphaout option.
INPUT/OUTPUT
rasttopnm reads the Sun rasterfile from standard input if no rasterfile argument is provided. The converted portable anymap image is written to standard output. This behavior makes it highly suitable for use in pipelines with other Netpbm tools.
NETPBM PHILOSOPHY
True to the Netpbm philosophy, rasttopnm is a simple, single-purpose tool. It focuses solely on the conversion from Sun raster to PBM/PGM/PPM, allowing subsequent tools in a pipeline to handle further image processing tasks like scaling, filtering, or conversion to other image formats.
HISTORY
rasttopnm is a component of the Netpbm package, a suite of graphics utilities that evolved from Jef Poskanzer's Pbmplus toolkit in the late 1980s. Pbmplus was developed to be a versatile toolset for image manipulation, emphasizing simple, pipe-able tools and portable image formats (PBM, PGM, PPM). rasttopnm was included to specifically handle the Sun rasterfile format, which was common on Sun Microsystems workstations. Its presence reflects the Netpbm project's aim to provide comprehensive format conversion capabilities. The Netpbm project continues to be actively maintained by Bryan Henderson.