Wolfram Language & System 10.3 (2015)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)

XBM (.xbm)


    MIME type: image/x-xbitmap
    X Window bitmap format.
    Used in the X11 windowing system for storing icons, cursors, and other graphics resources.
    ASCII format.
    Stores a monochrome bitmap as C language source code.
    XBM is an acronym derived from X BitMap.
    Developed in the 1980s at MIT.

Import and ExportImport and Export

  • Import["file.xbm"] imports an XBM file, returning an Image object.
  • Export["file.xbm",expr] exports graphics or any other expression as an image to XBM.
  • Export["file.xbm",expr] creates an XBM image with the same image size as the displayed form of .
  • Because XBM is a raster image format, all fonts are rasterized on export.
  • Import["file.xbm",elem] imports the specified element from an XBM file.
  • Import["file.xbm",{elem,suba,subb,}] imports a subelement.
  • Import["file.xbm",{{elem1,elem2,}}] imports multiple elements.
  • The import format can be specified with Import["file","XBM"] or Import["file",{"XBM",elem,}].
  • Export["file.xbm",expr,elem] creates an XBM file by treating expr as specifying element elem.
  • Export["file.xbm",{expr1,expr2,},{{elem1,elem2,}}] treats each as specifying the corresponding .
  • Export["file.xbm",expr,opt1->val1,] exports expr with the specified option elements taken to have the specified values.
  • Export["file.xbm",{elem1->expr1,elem2->expr2,},"Rules"] uses rules to specify the elements to be exported.
  • See the reference pages for full general information on Import and Export.
  • ImportString and ExportString support the XBM format.


  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Rules"full list of rules for each element and option
    "Options"list of rules for options, properties, and settings
  • Data representation elements:
  • "Data"array of color values
    "Graphics"Graphics object representing an image
    "GrayLevels"array of normalized gray-level values
    "Image"raster image represented as an Image object
    "RGBColorArray"array of RGBColor objects
  • Import and Export by default use the element for XBM files.
  • Advanced Import elements:
  • "BitDepth"bits used to represent each color channel in the file
    "ColorSpace"color encoding used in the file
    "ImageSize"raster dimensions


ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

This imports an XBM example file:

Click for copyable input

Import three metadata elements:

Click for copyable input

Importing as gives the entire original file as a string:

Click for copyable input
Introduced in 1999
| Updated in 2008