{"id":"image-x-xpixmap","mimeType":"image/x-xpixmap","name":"X Pixmap","shortName":"XPM","category":"Legacy \u0026 Raster Graphics","extensions":[".xpm"],"description":"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.","seo":{"title":"image/x-xpixmap MIME Type | Developer Reference for XPM","description":"Complete reference for the image/x-xpixmap MIME type: X Pixmap (XPM) format, X Window System color icons, C source code syntax, and transparency.","faqs":[{"question":"What is an XPM file?","answer":"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."},{"question":"Can I open an XPM file in a text editor?","answer":"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."},{"question":"Does XPM support transparency?","answer":"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."}]},"index":{"compression":["Uncompressed (Source Code)"],"browserSupport":{"score":1,"label":"None (Deprecated)"},"commonUses":["X Window System (X11) Application Icons and Cursors","Embedded C/C++ Firmware Color UI Assets","Early Linux Desktop Environment Themes"]},"technical":{"magicBytes":{"hex":"2F 2A 20 58 50 4D 20 2A 2F (ASCII '/* XPM */')","ascii":"/* XPM */"},"container":"C Source Code Header (.c / .h)","compressionAlgorithm":["None"],"colorDepth":["Indexed Color (Custom Palette with RGB and Alpha 'None')"],"transparency":true,"animation":false,"metadata":{"exif":false,"xmp":false,"iccProfile":false},"alphaChannel":true,"progressiveLoading":false,"hdrSupport":false},"history":{"developer":"Daniel Dardailler and Colas Nahaboo (Bull / X Consortium)","released":"1989","specification":"XPM Manual: The X Pixmap Format"},"browserSupport":{"chrome":false,"chromeVersion":"None","firefox":false,"firefoxVersion":"None","safari":false,"safariVersion":"None","edge":false,"edgeVersion":"None","internetExplorer":true},"softwareSupport":[{"name":"ImageMagick","logo":"image-magic.webp"},{"name":"GIMP","logo":"gimp.svg"},{"name":"XnView","logo":""},{"name":"GCC (GNU Compiler Collection - native compilation)","logo":""}],"conversion":{"convertTo":["png","xbm","bmp","gif"],"convertFrom":["png","bmp","xbm"]},"developer":{"httpHeaders":[{"header":"Content-Type","value":"image/x-xpixmap"},{"header":"Content-Type","value":"image/xpm"}],"htmlAccept":"image/x-xpixmap, .xpm","fileDetection":["XPM files are text files structured as C source code rather than binary files.","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).","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."]},"prosCons":{"pros":["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"],"cons":["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"]},"specifications":{"url":"https://www.x.org/","rfc":"","mimeAliases":["image/xpm","image/x-xpm","application/x-xpixmap"]},"developerSnippets":{"python":"import magic\n# Libmagic can identify XPM files by checking for the '/* XPM */' comment header\nprint(magic.from_file('icon.xpm', mime=True)) # Outputs 'image/x-xpixmap' or 'text/plain'","nodejs":"const fs = require('fs');\n// Reading the first 9 bytes to check for the '/* XPM */' signature\nconst buffer = Buffer.alloc(9);\nconst fd = fs.openSync('icon.xpm', 'r');\nfs.readSync(fd, buffer, 0, 9, 0);\nfs.closeSync(fd);\nconst isXPM = buffer.toString('ascii') === '/* XPM */';\nconsole.log('Is X Pixmap (XPM):', isXPM);","go":"import (\n    \"bytes\"\n    \"net/http\"\n)\n// Native Go HTTP detection may return text/plain because XPM is valid C source code.\n// Check directly for the /* XPM */ prefix:\n// isXPM := bytes.HasPrefix(buf, []byte(\"/* XPM */\"))","php":"$mime = mime_content_type('icon.xpm');\necho $mime; // May return 'image/x-xpixmap', 'image/xpm', or 'text/plain' depending on the system's magic database rules."},"relatedFormats":["png"]}
