From Just Solve the File Format Problem
Jump to: navigation, search
File Format
Name XPM
Extension(s) .xpm, .pm, .c, .h
MIME Type(s) image/x-xpixmap
PRONOM x-fmt/208
Wikidata ID Q1887604
Released 1989

X PixMap (XPM) is an uncompressed raster image file format. It is essentially the color version of XBM.

An XPM file is plain text. But some like the mentioned example dframeIB.xpm contain special characters like zero-byte or Control-Z at the end. These then no longer represent pure ASCII text, which leads to malfunction of some programs. Except for the little-used XPM version 2, it doubles as a fragment of C program code. Therefore, instead of the usual extension xpm for the file name, you can also find the suffix h as in the example progressui_gtk_icon.h or the suffix c as in the example xpmputty.c. In some cases these also contain other C expressions. Unfortunately, this leads to some confusion. On some systems, such examples are now considered as C header text or C source text based on the file extension. When trying to edit them, they are usually opened with a text editor like Emacs or vi. On other systems, however, the examples are viewed as X pixmap files based on the magic comment. When trying to edit them, they are then usually opened with an image editor.



X PixMap should start with 9 byte c-comment /* XPM */. All start with a c-comment, but in some non-standard examples the magic comment appears several hundred bytes later, as in the examples mozicon16.xpm or mozicon50.xpm. Or this comment is even completely missing as in the example logo.xpm. Most programs cannot handle these variants, but some software like ImageMagick or IrfanView can. Therefore, one should also check the part defined as C program code. This begins with the two consecutive words static char, which are separated by white space. This can be combinations of spaces and tabulation characters, but usually one space is used. This string is often found a few thousand bytes after the beginning as in the example mh-logo.xpm. The character array is defined without explicit length specification. This can be recognized by the 2 byte sequence of square brackets [].



Sample files

External links

Personal tools