Linux Commands Examples

A great documentation place for Linux commands


convert a portable pixmap into an X11 pixmap

see also : ppmcolormask - xpmtoppm


ppmtoxpm [-name=xpmname] [-rgb=rgb-textfile] [-alphamask=pgmfile] [ppmfile]

Minimum unique abbrevations are acceptable.

add an example, a script, a trick and tips

: email address (won't be displayed)
: name

Step 2

Thanks for this example ! - It will be moderated and published shortly.

Feel free to post other examples
Oops ! There is a tiny cockup. A damn 404 cockup. Please contact the loosy team who maintains and develops this wonderful site by clicking in the mighty feedback button on the side of the page. Say what happened. Thanks!


ppmcolormask rgb:C0/C0/C0 "$PPM_NAME" > "$MASK_NAME"
ppmtoxpm -name "$XPM_LABEL" -alphamask="$MASK_NAME" "$PPM_NAME" | perl -pe 's/ #(.)(.)(.)"/ #$1$1$2$2$3$3"/' > "$XPM_NAME"
ppmcolormask rgb:47/6c/6c ${ex_output}.ppm > /tmp/et$$.pbm
ppmtoxpm -alphamask=/tmp/et$$.pbm ${ex_output}.ppm > ${ex_output}.xpm
ppmcolormask rgb:47/6c/6c ${ex_output}-fs.ppm > /tmp/et$$.pbm
ppmcolormask rgb:47/6c/6c ${ex_output}-fs.ppm > /tmp/et$$.pbm
ppmtoxpm -alphamask=/tmp/et$$.pbm ${ex_output}-fs.ppm \
> ${ex_output}-fs.xpm
rm -f /tmp/et$$.pbm


Reads a portable pixmap as input. Produces X11 pixmap (version 3) as output which can be loaded directly by the XPM library.

For example, to convert the file "dot" (found in /usr/include/X11/bitmaps), from xbm to xpm one could specify

xbmtopbm dot | ppmtoxpm -name dot

or, with a rgb text file (in the local directory)

xbmtopbm dot | ppmtoxpm -name dot -rgb rgb.txt



The -name option allows you to specify the prefix string which is printed in the resulting XPM output. If not specified, will default to the filename (without extension) of the <ppmfile> argument. If you do not specify -name or ppmfile, (i.e. your input is from Standad Input), the prefix string defaults to the string noname.


The -rgb option allows you to specify an X11 rgb text file for the lookup of color name mnemonics. This rgb text file is typically the /usr/lib/X11/rgb.txt of the MIT X11 distribution, but any file using the same format may be used. When specified and a RGB value from the ppm input matches a RGB value from the <rgb-textfile>, then the corresponding color name mnemonic is printed in the XPM’s colormap. If you don’t specify -rgb or if the RGB values don’t match, then ppmtoxpm produces the color specifications in the #RGB, #RRGGBB, #RRRGGGBBB, or #RRRRGGGGBBBB hexadecimal format.


This option names a PGM file to use as an alpha (transparency) mask. The file must contain an image the same dimensions as the input image. ppmtoxpm marks as transparent any pixel whose position in the alpha mask image is at most half white.

If you don’t specify -alphamask, ppmtoxpm makes all pixels in the output opaque.

ppmcolormask is one way to generate an alpha mask file. You might also generate it by extracting transparency information from an XPM file with the -alphaout option to xpmtoppm. There are similar options on other Netpbm converters that convert from formats that include transparency information too.


An option to match the closest (rather than exact) color name mnemonic from the rgb text would be a desirable enhancement.

Truncation of the least significant bits of a RGB value may result in nonexact matches when performing color name mnemonic lookups.

see also

ppmcolormask , xpmtoppm , ppm
XPM Manual by Arnaud Le Hors lehors[:at:]mirsa.inria[:dot:]fr


Copyright (C) 1990 by Mark W. Snitily.

Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and that both that copyright notice and this permission notice appear in supporting documentation. This software is provided "as is" without express or implied warranty.

This tool was developed for Schlumberger Technologies, ATE Division, and with their permission is being made available to the public with the above copyright notice and permission notice.

Upgraded to XPM2 by
Paul Breslaw, Mecasoft SA, Zurich, Switzerland (paul[:at:]mecazh.uu[:dot:]ch)
Thu Nov 8 16:01:17 1990

Upgraded to XPM version 3 by
Arnaud Le Hors (lehors[:at:]mirsa.inria[:dot:]fr)
Tue Apr 9 1991

How can this site be more helpful to YOU ?

give  feedback