{"id":"image-x-xbm","mimeType":"image/x-xbm","name":"X Bitmap (Legacy MIME Alias)","shortName":"XBM","category":"Legacy \u0026 Raster Graphics","extensions":[".xbm"],"description":"The image/x-xbm MIME type is a common unofficial alias for the X Bitmap (XBM) format, a plain-text raster image format developed in the late 1980s for the X Window System (X11). Structurally formatted as valid C source code, an XBM file represents 1-bit monochrome (black and white) pixels as a static array of hexadecimal byte values that can be compiled directly into C or C++ programs. While 'image/x-xbitmap' is the more traditional long-form MIME identifier, 'image/x-xbm' is frequently encountered in legacy Apache/Nginx configurations, older web server mappings, and historic Unix application suites.","seo":{"title":"image/x-xbm MIME Type | Developer Reference for XBM Format","description":"Complete reference for the image/x-xbm MIME type: X Bitmap (XBM) format, X Window System C-header syntax, 1-bit monochrome graphics, and file detection.","faqs":[{"question":"What is the difference between image/x-xbm and image/x-xbitmap?","answer":"There is no difference in the underlying file. Both MIME types refer to the exact same XBM (X Bitmap) file format. 'image/x-xbm' is simply a shorter shorthand alias commonly used in web server configuration files like mime.types."},{"question":"Can I open an XBM file in a text editor?","answer":"Yes. Because an XBM file is literally written in C programming language syntax, you can open it in any text editor to view the image dimensions (`#define ... width/height`) and the array of hex values representing the pixels."},{"question":"How do I detect an XBM file programmatically?","answer":"Because XBM files are plain-text files written in C source code rather than binary files, they lack traditional binary magic numbers. You can detect them by checking if the file begins with the ASCII string '#define'."}]},"index":{"compression":["Uncompressed (Source Code)"],"browserSupport":{"score":1,"label":"None (Deprecated)"},"commonUses":["X Window System (X11) Cursors and Icons","Embedded C/C++ Firmware UI Assets","Early 1990s Unix Web Graphics"]},"technical":{"magicBytes":{"hex":"23 64 65 66 69 6e 65 (ASCII '#define')","ascii":"#define"},"container":"C Source Code Header (.h)","compressionAlgorithm":["None"],"colorDepth":["1-bit (Monochrome)"],"transparency":true,"animation":false,"metadata":{"exif":false,"xmp":false,"iccProfile":false},"alphaChannel":false,"progressiveLoading":false,"hdrSupport":false},"history":{"developer":"MIT / X Consortium (X Window System)","released":"1988","specification":"X Window System Protocol and Architecture Manual"},"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","xpm","bmp","gif"],"convertFrom":["png","bmp"]},"developer":{"httpHeaders":[{"header":"Content-Type","value":"image/x-xbm"},{"header":"Content-Type","value":"image/x-xbitmap"}],"htmlAccept":"image/x-xbm, image/x-xbitmap, .xbm","fileDetection":["Because XBM files are text files rather than binary files, traditional binary magic numbers do not apply.","To detect an XBM file programmatically, check if the file begins with standard C preprocessor directives, specifically the ASCII string '#define' (Hex: 23 64 65 66 69 6E 65).","When encountering 'image/x-xbm' in web server configurations or uploads, you can safely normalize it to 'image/x-xbitmap' or treat it as text-based 1-bit raster data."]},"prosCons":{"pros":["Can be compiled directly into C or C++ source code without needing an external file loader or binary asset manager","Human-readable structure allows developers to inspect, edit, or hand-craft tiny icons directly within a text editor","Extremely predictable and lightweight for 1-bit hardware displays and embedded systems"],"cons":["Strictly limited to 1-bit monochrome (black and white) graphics with no gray or color support","Text-based C syntax creates massive file bloat compared to binary 1-bit formats like PBM","Completely deprecated in modern web browsers and desktop GUI frameworks"]},"specifications":{"url":"https://www.x.org/","rfc":"","mimeAliases":["image/x-xbitmap","image/xbm","application/x-xbitmap"]},"developerSnippets":{"python":"import magic\n# Libmagic can identify XBM files by scanning the text content for C preprocessor macros\nprint(magic.from_file('icon.xbm', mime=True)) # Outputs 'image/x-xbitmap' or 'text/plain'","nodejs":"const fs = require('fs');\n// Reading the first few bytes to check for the '#define' C preprocessor directive\nconst buffer = Buffer.alloc(7);\nconst fd = fs.openSync('icon.xbm', 'r');\nfs.readSync(fd, buffer, 0, 7, 0);\nfs.closeSync(fd);\nconst isXBM = buffer.toString('ascii') === '#define';\nconsole.log('Is X Bitmap (XBM):', isXBM);","go":"import (\n    \"bytes\"\n    \"net/http\"\n)\n// Native Go HTTP detection will likely return text/plain because XBM is valid source code.\n// Check directly for the #define prefix:\n// isXBM := bytes.HasPrefix(buf, []byte(\"#define\"))","php":"$mime = mime_content_type('icon.xbm');\necho $mime; // May return 'image/x-xbm', 'image/x-xbitmap', or 'text/plain' depending on the system's magic database rules."},"relatedFormats":[]}
