LinuxCommandLibrary

xpmtoppm

Convert X PixMap (XPM) image to PPM

TLDR

Convert an XPM image to a PPM image

$ xpmtoppm [path/to/input_file.xpm] > [path/to/output_file.ppm]
copy

Store the transparency mask of the input image in the specified file
$ xpmtoppm [[-a|--alphaout]] [path/to/alpha_file.pbm] [path/to/input_file.xpm] > [path/to/output_file.ppm]
copy

SYNOPSIS

xpmtoppm [options] [xpmfile]

PARAMETERS

-verbose
    Prints informative messages about the conversion process.

-alphaout=alpha-file
    Writes the alpha channel of the XPM image to a separate PGM (Portable GrayMap) file named alpha-file.

-headercomment=comment
    Inserts the specified comment string into the header of the output PPM file.

-map=filename
    Uses colors from the specified PPM or PGM image file (filename) for color mapping in the output.

-map-ignore-missing
    Prevents the command from failing if a color from the input XPM is not found in the specified map file.

-keep-pixmap-size
    Preserves the original pixmap size without trimming any border (default behavior might remove border).

-map-zero-to-black
    Maps the XPM color 'None' (transparent) to black instead of keeping it transparent (or background color).

-map-not-zero-to-white
    Maps any non-transparent color in the XPM to white.

-map-to-gray
    Converts the output to grayscale instead of full color.

-map-to-bw
    Converts the output to black and white, applying dithering for smooth transitions.

-color-from-rgb.txt
    Uses colors defined in the standard system 'rgb.txt' file for color lookup.

-color-from-rgb.txt-all
    Uses all colors (not just a subset) from the standard 'rgb.txt' file for color lookup.

-no-rgb-txt
    Disables the use of any 'rgb.txt' file for color lookup.

-rgb-txt=filename
    Specifies an alternative 'rgb.txt' file to use for color lookup.

-gamma=gamma_value
    Applies gamma correction with the specified gamma_value to the output image.

-preserve-gamma
    Attempts to preserve the gamma information from the input XPM in the output PPM.

-invert-color-map
    Inverts the colors of the output image based on the color map.

-no-pixels
    Outputs only the PPM header, without any pixel data.

-plain-ppm
    Outputs the PPM in plain (ASCII) format. Synonym for -plain.

-plain
    Outputs the PPM in plain (ASCII) format. Synonym for -plain-ppm.

-comment=string
    Adds a user-defined string as a comment to the output PPM header.

-no-comments
    Prevents copying any comments from the input XPM file to the output PPM.

-version
    Displays the version information for xpmtoppm.

xpmfile
    The path to the input XPM file. If omitted, xpmtoppm reads from standard input.

DESCRIPTION

xpmtoppm is a powerful utility from the Netpbm package designed to convert XPM (X PixMap) format image files into PPM (Portable PixMap) format. XPM is a text-based image format frequently used for icons and small graphics within the X Window System environment. PPM, on the other hand, is a simple, uncompressed pixelmap format that serves as a versatile intermediate for conversions to and from many other image types within the Netpbm toolkit. The command reads XPM data from standard input if no file is specified, and outputs the resulting PPM data to standard output, making it ideal for piping operations with other Netpbm tools. It provides various options for color mapping, gamma correction, and output formatting to control the conversion process.

CAVEATS

XPM is a relatively older image format, primarily associated with the X Window System. While xpmtoppm handles most XPM variants, complex or non-standard XPM files might not be converted perfectly. Transparency in XPM is handled by converting it to Netpbm's alpha channel (if supported by other tools) or by mapping it to a solid color based on options. For modern web or application use, PNG or JPEG are generally preferred over XPM and PPM.

INPUT AND OUTPUT

xpmtoppm is designed for use in shell pipelines. It reads XPM data from standard input if no xpmfile is specified, and always writes the resulting PPM data to standard output. This allows easy chaining with other Netpbm commands or redirection to a file.

Example:
cat myimage.xpm | xpmtoppm > myimage.ppm

NETPBM INTEGRATION

Being a core component of the Netpbm project, xpmtoppm integrates XPM images into a robust framework for image manipulation. Once an XPM is converted to PPM, it can be further processed by hundreds of other Netpbm utilities (e.g., pnmscale, pnmcrop, pnmflip) or converted to virtually any other image format using tools like pnmtopng, pnmtojpeg, etc.

HISTORY

xpmtoppm is an integral part of the Netpbm project, a suite of graphics utilities that originated from Jef Poskanzer's pbmplus package in 1988. The creation of xpmtoppm was driven by the necessity to bridge the specialized XPM format, common in the X Window System, with the versatile Netpbm ecosystem. This allowed XPM images to be seamlessly processed, manipulated, and converted to numerous other formats through the extensive collection of Netpbm tools, thereby enhancing interoperability between different image handling systems during the early days of graphical computing on Unix-like systems.

SEE ALSO

ppmtoxpm(1), ppm(5), netpbm(1), anytopnm(1)

Copied to clipboard