PPMTOXPM(1)
π ppmtoxpm β a Gen Z guide to converting PPM to X11 pixmap π
okay bestie, welcome to the Ppmtoxpm User Manual, section 1 of the General Commands Manual. this is a Netpbm girlie and she's here to turn your PPM into an X11 pixmap. let's get into it π«Ά
β¨ NAME β¨
ppmtoxpm β convert a PPM image to an X11 pixmap
π¦ SYNOPSIS π¦
ppmtoxpm [-name=xpmname] [-hexonly] [-rgb=rgb-textfile]
[-alphamask=pgmfile] [ppmfile]
Minimum unique abbreviation of option is acceptable. You may use double hyphens instead of single hyphen to denote options. You may use white space in place of the equals sign to separate an option name from its value.
ngl that's just fancy talk for "yeah you can shorten the flags and yeah-name fooand-name=fooboth hit." lowkey convenient π
πΈ DESCRIPTION πΈ
This program is part of Netpbm(1). (hi family π)
ppmtoxpm reads a PPM image as input and produces X11 pixmap (version 3) as output. This format can be loaded by the XPM library. it's giving glow-up, but for file formats β¨
In the XPM output, colors may be identified by name, such as "Red", or in hexadecimal, for example "#FF0000". In the hexadecimal format, there may be from 1 through 4 hexadecimal digits per RGB component.
By default, ppmtoxpbm tries to find a name for each color in the image in the system color dictionary, and if it finds one, uses it. If it doesn't it uses hexadecimal. You can force ppmtoxpbm to use hexadecimal only with the -hexonly option. You can specify a different color dictionary with the -rgb option.
When ppmtoxpm uses the hexadecimal format for identifying a color, it uses the one that uses the least number of hexadecimal digits that it takes to represent the maxval of the input PPM. E.g. if the maxval of the input PPM is 100, ppmtoxpm uses 2 digits per component, as in "#FF0000". so it's always doing the most economical little thing, periodt π
β οΈ Some programs do not properly handle one-digit-per-component hexadecimal color specifiers. They see the wrong colors. To produce an XPM that such a program can handle, make sure the maxval of the input PPM is greater than15, such as by running it throughpamdepth 255. like, do the little fix or those programs will simply be wrong and that's embarrassing for everyone π
π¨ Color Code Lengths - Image Size π¨
In the XPM format, there is a palette ("color map") that assigns each color in the image to a unique sequence of printable characters called a color code, and a raster that identifies the color of each pixel of the image with one of those color codes. The length of the color code affects the size of the image stream. okay so it's a little lookup table plus a pixel map, and the length of the codes literally changes how big your file gets. the way that size math matters π©
All color codes in an image are the same length, and ppmtoxpm tries to make it as short as possible. That length is, of course, determined by the number of colors in the image. ppmtoxpm counts the colors in the image, excluding those that will be transparent in the output because of your transparency mask, and chooses a color code length accordingly. There are 92 printable characters that can be used in a color code. Therefore, if you have 92 or fewer colors, your color codes will be one character. If you have more than 92 but not more than 92 * 92, your color codes will be two characters. And so on. math queen behavior fr fr π
There's one exception to the above: If you specify a transparency mask (the -alpha option, one unique color code represents "transparent." This is true even if the transparency mask doesn't actually produce any transparent pixels. So subtract one from the number of possible colors if you use -alpha. so real talk, transparency eats a color slot whether you use it or not. iconic of it honestly π
π OPTIONS π
In addition to the options common to all programs based on libnetpbm (most notably -quiet, see Common Options), ppmtoxpm recognizes the following command line options:
-name=xpmnameβ This option specifies the prefix string which is specified in the resulting XPM output. If you don't use the-nameotpion,ppmtoxpmdefaults to the filename (without extension) of theppmfileparameter. If you do not specify-nameorppmfile(i.e. your input is from Standard Input), the prefix string defaults to the stringnoname. so like, name your baby or it'll get auto-named after the file, and if there's no file at all it's literally justnonameπ-hexonlyβ This option says never to put color names in the XPM file, but rather to identify names by hexadecimal strings that explicitly identify RGB component intensities. This means the reader of the file need not have access to a suitable color dictionary to interpret it.
This option was introduced in Netpbm 10.15 (April 2003). Before that, it was the default, overridden by specifying -rgb. throwback era fr, she used to be the default and she's not mad about it, she's just saying π
-rgb=rgb-textfileβ This option names the file in which the color dictionary you want to use resides. By default,ppmtoxpmuses the system color dictionary, and if it cannot open that file, uses hexadecimal color specifiers.
This option in meaningless when you specify -hexonly. (read that as: if you said hex only, this one does literally nothing. canceled β)
Before Netpbm 10.15 (April 2003), ppmtoxpm did not default to the system color dictionary. If you didn't specify -rgb, ppmtoxpbm would use only hexadecimal color specifiers. history lesson bestie, she's evolved πβ¨
-alphamask=pgmfileβ This option names a PGM file to use as a transparency (alpha) mask. The file must contain an image the same dimensions as the input image.ppmtoxpmmarks as transparent any pixel whose position in the transparency mask image is at most half white.
If you don't specify -alphamask, ppmtoxpm makes all pixels in the output opaque. no mask, no transparency, everyone's solid, periodt π«Ά
ppmcolormask is one way to generate a transparency 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. the transparency sisters are everywhere, iykyk π¦
π₯ SEE ALSO π₯
ppmcolormask(1)xpmtoppm(1)pamdepth(1)ppm(1)- XPM Manual by Arnaud Le Hors
lehors@mirsa.inria.fr
π AUTHOR π
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@mecazh.uu.ch), November 8, 1990.
Upgraded to XPM version 3 by Arnaud Le Hors (lehors@mirsa.inria.fr), April 9, 1991.
π DOCUMENT SOURCE π
This manual page was generated by the Netpbm tool 'makeman' from HTML source. The master documentation is at
http://netpbm.sourceforge.net/doc/ppmtoxpm.html
okay that's the whole thing, no cap. this page lives in the netpbm documentation, dated 22 February 2003, and it's the Ppmtoxpm User Manual(1) β so if you ever forget where you read all this, it was the netpbm girls, February 22, 2003, section 1 of the general commands manual. slay and happy converting πβ¨π¦
π¦ where this page comes from
- debian bookworm: netpbm 2:11.01.00-2 Β· MIT
- debian trixie: netpbm 2:11.10.02-1 Β· MIT
- ubuntu noble: netpbm 2:11.05.02-1.1build1 Β· MIT
- ubuntu resolute: netpbm 2:11.10.02-1build1 Β· MIT
- ubuntu stonking: netpbm 2:11.13.03+ds-2 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms