Free XPM test files and sample generator
An X11 pixmap: an image written as C source. Generate valid .xpm sample files to test image viewers, converters and legacy Unix tooling.
What is a .xpm file?
XPM: X PixMap Image. XPM is an X11 pixmap written as C source code, an array of strings, one per pixel row, with a small color table. It can be compiled directly into a program, which is why old Unix applications embed icons this way.
Why generate a test XPM file?
- Test legacy Unix or X11 asset tooling.
- Verify a parser that reads images out of source code.
- Check that a build step handles an image that is also compilable C.
What you can put inside a .xpm file
You get 2 content options for XPM, so the file holds something meaningful rather than random padding: Solid color, Checkerboard. For XPM these are alternatives, so choose the one that matches what you need to test.
How a .xpm file is identified
A .xpm file has no signature at the start. XPM is C source code: it starts with a comment and declares a string array, so it is identified by content rather than by leading bytes.
How the size lands on the exact byte
C comments carry the padding, which is why the file stays compilable as well as viewable.
Negative testing with broken XPM files
- Invalid. Identifiable, but wrong inside, so it fails during parsing.
- Corrupted. The leading bytes are destroyed. Same length as the valid file.
- Incomplete. Truncated part-way, so it is genuinely shorter.
- Empty. Chosen under Content rather than File Condition: valid structure, no data.
Which failure to reach for, and what to assert for each, is covered in how to make a corrupted file for testing. For upload limits and type checks see testing file upload validation.
Sample XPM content
/* XPM */
static char * softwaretestdata_xpm[] = {
"64 32 2 1",
" c #0E7490",
". c #FFFFFF",
…
};This shows the shape of the file. Your download is generated fresh at the size you choose, so the values will differ.
How to open and verify the file
Open in GIMP or IrfanView; it is also valid C, so a compiler will accept it.
Media type image/x-xpixmap · extension .xpm · category Images
Generate a .xpm file → · questions about sizes, privacy or cost are answered on the site FAQ.
Frequently asked questions about XPM files
What identifies a .xpm file?
Nothing at the start of the file does. XPM is C source code: it starts with a comment and declares a string array, so it is identified by content rather than by leading bytes.
How can a .xpm file be an exact number of bytes?
C comments carry the padding, which is why the file stays compilable as well as viewable.
What can go inside the XPM file?
There are 2 content options for .xpm: Solid color, Checkerboard. For XPM these are alternatives, so pick the one matching what you need to test.
Can I download several broken XPM files at once?
Yes, select more than one File Condition and you get one ZIP containing a .xpm per condition, each named after its condition.
Can the XPM file use UTF-16 or a byte-order mark?
No, and deliberately. A .xpm file is a container rather than plain text, so rewriting its bytes as UTF-16 would not produce a UTF-16 document. It would produce a broken file. Use a text format such as CSV, JSON or XML for encoding tests.
How do I open or verify the XPM file?
Open in GIMP or IrfanView; it is also valid C, so a compiler will accept it.