LinuxCommandLibrary

pnmtosgi

Convert PNM image to Sun rasterfile image

TLDR

Convert a PNM image to an SGI image

$ pnmtosgi [path/to/input.pnm] > [path/to/output.sgi]
copy

Disable or enable compression
$ pnmtosgi -[verbatim|rle] [path/to/input.pnm] > [path/to/output.sgi]
copy

Write the specified string into the SGI image header's imagename field
$ pnmtosgi [[-i|-imagename]] [string] [path/to/input.pnm] > [path/to/output.sgi]
copy

SYNOPSIS

pnmtosgi [-rle] [-alpha] [pnmfile] > sgiimagefile

PARAMETERS

-rle
    Use run-length encoding for compressed image data (default: verbatim)

-alpha
    Add fully opaque alpha channel (all values 255)

DESCRIPTION

pnmtosgi is a Netpbm utility that converts portable anysmap images (PBM bitmaps, PGM grayscale, or PPM pixmaps) into the SGI image format.

The SGI format originated with Silicon Graphics workstations and supports RGB images with 8 bits per channel, optional run-length encoding (RLE), and an alpha channel. Grayscale or monochrome inputs are converted to RGB by replicating channels (e.g., grayscale values set R=G=B). Input pixel values are scaled to 8-bit range.

By default, pnmtosgi produces uncompressed (verbatim) RGB data on stdout. The -rle option enables RLE compression for smaller files. -alpha adds a fourth channel with all pixels fully opaque (alpha=255). Output images have dimensions matching input, with z-dimension 1 (no volume data).

Standard Netpbm conventions apply: input from stdin or named file; multiple files not supported. Ideal for legacy SGI workflows or tools like sgifilt.

CAVEATS

Always produces RGB output; no colormap support. Limited to 8-bit/channel. SGI viewers may expect specific header properties. Large images may exceed some tools' limits.

EXAMPLES

pnmtosgi image.ppm > image.sgi
pnmtosgi -rle -alpha input.pgm > output.sgi

NOTES

Options abbreviate to unique prefixes (e.g., -r, -a). Reads stdin if no pnmfile.

HISTORY

Part of Netpbm suite since early 1990s; developed by Jef Poskanzer and contributors. SGI format from 1980s Silicon Graphics IRIS systems, now legacy.

SEE ALSO

sgitopnm(1), pnm(5), ppm(5), netpbm(1)

Copied to clipboard