Free webp to jpg
XPM

X Pixmap

image/x-xpixmap Released 1989 · by Daniel Dardailler and Colas Nahaboo (Bull / X Consortium)

The image/x-xpixmap MIME type represents the X Pixmap (XPM) format, a plain-text raster image format developed in 1989 by Daniel Dardailler and Colas Nahaboo at Bull, and later refined for the X Window System (X11). Building upon the concept of the 1-bit XBM (X Bitmap) format, XPM introduced full color support and transparency by formatting images as valid C programming language source code. An XPM file typically contains a color palette mapping single- or multi-character symbols to color codes (such as RGB hex values or 'None' for transparency), followed by an array of strings representing the 2D pixel grid. It was heavily used for icons, toolbar buttons, and UI themes in early Unix/Linux desktop environments.

Legacy & Raster Graphics Transparency Production Ready

Technical Specifications

MIME Type
image/x-xpixmap
Extensions
.xpm
Container
C Source Code Header (.c / .h)
Compression
Uncompressed (Source Code)
Algorithms
None
Color Depth
Indexed Color (Custom Palette with RGB and Alpha 'None')
Metadata
None
Capabilities
Transparency
Animation
Progressive Loading
Alpha Channel
HDR Support
Official Specification
Aliases: image/xpmimage/x-xpmapplication/x-xpixmap

Magic Bytes & HTTP Headers

File Signature (Magic Bytes)
2F 2A 20 58 50 4D 20 2A 2F (ASCII '/* XPM */')
ASCII: /* XPM */
HTTP Headers
Content-Type: image/x-xpixmap
Content-Type: image/xpm
HTML Accept Attribute
accept="image/x-xpixmap, .xpm"

Browser Support Matrix

Browser Status Min Version
Chrome Chrome
Not Supported
Firefox Firefox
Not Supported
Safari Safari
Not Supported
Edge Edge
Not Supported
Internet Explorer Internet Explorer
Supported Legacy

Advantages & Limitations

Advantages
  • Can be compiled directly into C or C++ source code without requiring an external asset loading mechanism
  • Human-readable palette mapping allows developers to inspect, modify, or hand-craft icons directly within a text editor
  • Native support for color palettes and transparency via the 'None' keyword
Limitations
  • Extremely inefficient storage structure for large images, resulting in massive file bloat compared to binary formats like PNG
  • Completely obsolete and unsupported in modern web browsers
  • Parsing overhead requires compiling or interpreting text-based color tables at runtime

Developer Code Snippets

import magic
# Libmagic can identify XPM files by checking for the '/* XPM */' comment header
print(magic.from_file('icon.xpm', mime=True)) # Outputs 'image/x-xpixmap' or 'text/plain'
const fs = require('fs');
// Reading the first 9 bytes to check for the '/* XPM */' signature
const buffer = Buffer.alloc(9);
const fd = fs.openSync('icon.xpm', 'r');
fs.readSync(fd, buffer, 0, 9, 0);
fs.closeSync(fd);
const isXPM = buffer.toString('ascii') === '/* XPM */';
console.log('Is X Pixmap (XPM):', isXPM);
import (
    "bytes"
    "net/http"
)
// Native Go HTTP detection may return text/plain because XPM is valid C source code.
// Check directly for the /* XPM */ prefix:
// isXPM := bytes.HasPrefix(buf, []byte("/* XPM */"))
$mime = mime_content_type('icon.xpm');
echo $mime; // May return 'image/x-xpixmap', 'image/xpm', or 'text/plain' depending on the system's magic database rules.

File Detection Steps

How to programmatically detect a image/x-xpixmap file by reading its raw bytes:

  1. 1 XPM files are text files structured as C source code rather than binary files.
  2. 2 To reliably detect an XPM file programmatically, check if the file begins with the C comment block signature '/* XPM */' (Hex: 2F 2A 20 58 50 4D 20 2A 2F).
  3. 3 Following the comment header, a valid XPM file will contain a static `static char *...` array declaration defining the width, height, number of colors, and characters per pixel.

Software Support

ImageMagick ImageMagick
GIMP GIMP
X
XnView
G
GCC (GNU Compiler Collection - native compilation)

Conversion Tools

Share & Embed

Markdown Badge
XPM Format Badge
[![XPM Format](https://freewebptojpg.com/mime/image/xpm/badge.svg)](https://freewebptojpg.com/mime/image/xpm)
Interactive iframe Widget
<iframe src="https://freewebptojpg.com/mime/image/xpm/embed" width="100%" height="280" style="border:1px solid #cbd5e1;border-radius:8px;" title="XPM Specs"></iframe>

JSON API

All data on this page is available as a free, open JSON API. Use it in your project, documentation, or tooling.

GET https://freewebptojpg.com/mime/image/xpm.json Open JSON
Free to use
No auth required
CORS enabled
Use from any domain
Cached 24h
Cache-Control headers set

Frequently Asked Questions

What is an XPM file?

An XPM (X Pixmap) file is a plain-text color image format created for the X Window System. Like XBM, it is written as valid C programming language source code, allowing developers to embed color icons and cursors directly into C/C++ applications.

Can I open an XPM file in a text editor?

Yes. Because XPM files are text files structured as C source code arrays, you can open them in any text editor to view the header dimensions, color symbol lookup table, and the character-grid representation of the image.

Does XPM support transparency?

Yes. One of XPM's major advancements over XBM was its ability to define a transparent color mapping using the keyword 'None' in the palette definition.

Related Formats

Share this format