Introduction
XPM is a colour image format for icons and small pictures in the X Window System. Like XBM, an XPM file is C source code that a program can compile in, but it holds colours and transparency. Each pixel is written as one or more characters, so the picture can be read, and even drawn, in a text editor.
Arnaud Le Hors wrote the format and its library, libXpm, at Groupe Bull. It was widely used for the icons of Unix desktops and programs, and many toolkits still read it.
Structure
The file starts with the comment /* XPM */, then declares an array of
strings. The first string gives the width, height, number of colours and characters
per pixel, optionally followed by a hotspot. One string per colour follows, giving the
characters and the colour for each display type: c for colour,
g for greyscale, m for mono and s for a
symbolic name. The colour None marks transparent pixels. The remaining
strings are the rows of pixels, from the top.
/* XPM */
static char *dot[] = {
"5 5 2 1",
" c None",
". c #FF0000",
" ... ",
".....",
".....",
".....",
" ... "};
Links
Software
- GIMP (Windows, macOS, Linux)
- ImageMagick (Windows, macOS, Linux)
Developers
- libXpm, the C library that reads and writes XPM