What is XPM? X PixMap Format Explained
A color X Window System icon format storing pixmaps as C-compatible ASCII text.
Last updated:
What is XPM?
XPM (X PixMap) is an image format used by the X Window System, created in 1989 at the Bull Research Center in France by Daniel Dardailler and Colas Nahaboo, and later enhanced by Arnaud Le Hors. It was designed primarily for color icon pixmaps and supports transparent pixels.
An XPM file is plain text, either in the XPM2 form or as a C character-string array that can be included directly in a C program. The data is organized into sections for values (width, height, color count, characters per pixel), a color table mapping character codes to colors, the pixel rows, and optional extensions. Colors can be hex codes or X11 color names, and the keyword None marks transparency.
How XPM Works
An XPM file, short for X PixMap, is the color successor to the monochrome XBM format, and it shares XBM's most distinctive trait: the file is valid C source code. An XPM stores an image as a C array of strings that a program can include and compile directly, so the picture travels as text that a compiler can read.
The first string in the array is a header that lists four numbers: the width, the height, the number of colors used, and the number of characters per pixel. Allowing more than one character per pixel is what lets XPM describe images with many distinct colors, since each color needs its own unique character code.
After the header comes one string for each color, mapping an ASCII character (or group of characters) to a color value. A color can be given as a named color, as a hexadecimal value, or as the special keyword None, which marks that character as fully transparent. This gives XPM a real, if simple, form of transparency that XBM lacks.
Finally, the array contains one string per row of the image. Each character in a row references one of the color entries defined above, so reading the image is a matter of looking up each character in the color table. Because every part of the file is ordinary C text, the whole pixmap can be compiled straight into a program.
History and Standardization
XPM appeared in the late 1980s within the ecosystem of the X Window System, as a direct answer to the limitations of the monochrome XBM format. As graphical Unix applications began using color, developers needed a way to describe color icons that was as easy to embed in source code as XBM had been.
The format became widely used for application icons and toolbar images across X11 and Linux desktop software, including many programs built on older toolkits and early versions of common widget libraries. Its ability to include an image simply by compiling a C array made it a natural fit for the source-driven world of Unix development.
Like XBM, XPM was never ratified by a formal international standards body. It grew as a convention of the X Window System and its toolkits, and its widespread support in Unix graphics libraries is what turned it into a stable de facto standard for embedded icons on those platforms.
XPM Compared to XBM, PNG, and SVG
Compared to its sibling XBM, XPM is a clear step up. XBM is limited to two colors and offers no transparency, while XPM supports full color and a working None transparency value. That made XPM the better choice whenever an icon needed more than a plain black-and-white silhouette.
Compared to PNG, XPM is inefficient. Because it stores the image as human-readable C text, an XPM file is verbose and much larger than an equivalent compressed binary PNG, which also offers deeper color and smooth alpha transparency rather than a single all-or-nothing transparent color.
Compared to SVG, which is vector-based and scales cleanly to any size, XPM is a fixed-resolution raster and does not scale without quality loss. For modern interface icons, PNG and SVG have almost entirely displaced it. XPM remains legacy but is still occasionally encountered in older Unix and Linux source trees, where its compile-in-place convenience once made it popular.
MKV Technical Specifications
XPM vs Other Image Formats
| Feature | XPM | PNG | GIF |
|---|---|---|---|
| Type | Raster | Raster | Raster |
| Color depth | Palette, color[1] | Up to 16-bit | 8-bit palette |
| Encoding | C source code[1] | Binary | Binary |
| Transparency | Yes[2] | Yes | Yes (1-bit) |
| Compression | None[1] | Lossless | Lossless (LZW) |
| Best for | X11 color icons[1] | Web graphics | Simple animation |
XPM extends the X11 pixmap concept to color icons stored as C code, useful in toolkits but not for general or web image delivery.
Advantages & Disadvantages
Advantages
Unlike XBM, XPM stores color images and supports a transparent color via the None keyword, ideal for icons.
As a C character-string array, an XPM pixmap can be included and compiled directly into an application.
XPM accepts X11 color names as well as hex codes, and can declare color, grayscale and monochrome variants per pixel.
The plain-text structure can be viewed and edited in any text editor, which is handy for small icons.
Disadvantages
Storing pixels as ASCII character codes makes XPM bulky and unsuitable for photographs or large graphics.
XPM is primarily an X Window System icon format and is uncommon outside that and developer contexts.
While some editors support it, XPM has narrower support than mainstream formats like PNG.
Common Use Cases
XPM is mainly used for color icons and small graphics in X Window System software.
Application and toolbar icons
XPM was widely used to define color icons for X11 applications and desktop environments.
Compiled-in pixmaps
Developers embed XPM data directly in C source so icons ship inside the program binary.
Window manager graphics
X-based window managers and toolkits use XPM for small color UI elements that need transparency.
Convert XPM Files Free
Use our free online converter to convert XPM and other formats - no signup, no watermarks.
Try Image Converter FreeHow to open a XPM file
XPM files, or X PixMap files, are primarily used for storing pixel-based images in a format that is particularly popular in the Unix/Linux environment. Software for handling XPM files can be categorized into professional graphic design tools, free and open-source applications, web-based viewers, and built-in utilities in various operating systems. Professional tools are suited for users needing advanced editing capabilities, while free and open-source options cater to casual users and developers. Browser-based tools provide quick access without installation, and built-in utilities offer basic functionality for quick viewing.
When choosing software for XPM files, several decision factors come into play, including feature fidelity for editing and viewing, the cost model of the software, platform compatibility, and any export needs for different formats. Users should consider whether they need extensive editing features or simple viewing capabilities, as well as whether they prefer a free solution or are willing to invest in a professional-grade application. Additionally, for users who only need to convert XPM files to more widely used formats, using a conversion tool might be a more efficient option.
GIMP 2.10.34
GIMP is a powerful open-source image editor that supports XPM files natively. It allows users to view, edit, and export XPM images with high fidelity, making it suitable for both casual and professional use.
- Full layer and mask editing
- Advanced color manipulation tools
- Customizable brushes and patterns
- Support for multiple file formats
- Extensive plugin support for enhancements
- Highly customizable user interface
- Robust community and support resources
- Comprehensive editing features for XPM
- Steeper learning curve for beginners
- Performance can lag on older hardware
Exports to: PNG, JPG, TIFF, BMP, GIF
Best for: GIMP is ideal for users seeking a free, comprehensive editing tool for XPM files with extensive capabilities.
Visit GIMP →ImageMagick 7.1.0-13
ImageMagick is a command-line tool that provides powerful image manipulation capabilities, including support for XPM files. It is particularly useful for batch processing and converting XPM images to other formats.
- Batch processing of images
- Conversion to multiple formats
- Image resizing and optimization
- Support for image annotations
- Extensive command-line options
- Highly efficient for batch operations
- Lightweight and fast performance
- Versatile format support for conversions
- Command-line interface may deter some users
- Limited graphical editing capabilities
Exports to: PNG, JPG, GIF, TIFF, PDF
Best for: ImageMagick is perfect for users who need a powerful command-line tool for processing XPM files efficiently.
Visit ImageMagick →XnView MP 1.0.0
XnView MP is a versatile image viewer and converter that supports XPM files among many other formats. It offers a user-friendly interface for viewing and basic editing of XPM images.
- Multi-format image viewing
- Basic editing tools like cropping
- Batch conversion capabilities
- Metadata editing and management
- Slideshow and presentation features
- Intuitive interface for easy navigation
- Supports a wide range of formats
- Efficient batch processing options
- Limited advanced editing features
- Paid version required for some features
Exports to: PNG, JPG, TIFF, GIF, BMP
Best for: XnView MP is suitable for users looking for a straightforward viewer and converter for XPM files with basic editing needs.
Visit XnView MP →Paint.NET 4.3.12
Paint.NET is a free image editing software for Windows that supports XPM files through plugins. It provides a simple interface for basic editing tasks and is suitable for casual users.
- Layer support for image composition
- Basic drawing and painting tools
- Plugin support for extended functionality
- Simple user interface for beginners
- Undo history for easy corrections
- User-friendly for beginners
- Lightweight and fast performance
- Active community for plugin development
- Limited advanced editing features
- XPM support requires additional plugins
Exports to: PNG, JPG, BMP, TIFF, GIF
Best for: Paint.NET is ideal for casual users seeking a simple and effective tool for basic XPM editing and viewing.
Visit Paint.NET →