XPM

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  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 or the suffix c as in the example. 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.

Identification
X PixMap should start with 9 byte c-comment. All start with a c-comment, but in some non-standard examples the magic comment appears several hundred bytes later, as in the examples  or. Or this comment is even completely missing as in the example. 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. The character array is defined without explicit length specification. This can be recognized by the 2 byte sequence of square brackets.

Specifications

 * XPM Manual: The X PixMap Format, Version 3.4i

Software

 * Farbfeld Utilities (format 1, 2 (except Lisp mode), and 3)
 * FFmpeg
 * ImageMagick (format 3 only)
 * Netpbm: ppmtoxpm, xpmtoppm (format 1 and 3)
 * libXpm:
 * https://gitlab.freedesktop.org/xorg/lib/libxpm
 * http://www.x.org/releases/individual/lib/ → libXpm-3.5.14.tar.gz
 * abydos
 * GIMP
 * IrfanView
 * LibreOffice Draw
 * XnView

Sample files

 * http://www.fileformat.info/format/xpm/sample/index.htm
 * http://stuff.mit.edu/afs/athena/contrib/graphics/images/icons/
 * https://telparia.com/fileFormatSamples/image/xpm/
 * https://www.qemu.org/ - qemu-7.0.0-rc4.tar.xz → logo.xpm
 * http://ftp.mozilla.org/pub/thunderbird/ - thunderbird-60.5.3.source.tar.xz → mozicon16.xpm mozicon50.xpm
 * https://archive.apache.org/dist/openoffice/ - apache-openoffice-4.1.7-46059c9192-src.zip → aoo-4.1.7/main/padmin/source/ psetupl.xpm
 * http://raspbian.raspberrypi.org/ - icewm-themes_1.2.26.orig.tar.gz → icewm-themes-1.2.26/gnomeish/ dframeIB.xpm
 * http://ftp.gnu.org/gnu/emacs/ - emacs-28.1.tar.gz → emacs-28.1/etc/images/ mh-logo.xpm
 * https://the.earth.li/~sgtatham/putty/0.76/ putty-0.76.tar.gz → putty-0.76/unix/ xpmputty.c
 * https://www.libreoffice.org/download/download/ libreoffice-7.3.2.2.tar.xz → libreoffice-7.3.2.2/onlineupdate/source/update/updater/ progressui_gtk_icon.h