Wolfram Language & System 10.4 (2016)|Legacy Documentation

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

PBM (.pbm)

  • Import and Export fully support the PBM format.
  • Export creates binary PBM files.
  • If multiple images are present in a PBM file, Import returns the first of the images.


    MIME type: image/x-portable-bitmap
    PBM monochrome raster image format.
    Member of the Portable family of image formats.
    Related to PGM and PPM.
    Implements a subset of the PNM format.
    Native format of the Netpbm graphics software package.
    Primarily used as an intermediate file format on Unix systems.
    PBM is an acronym derived from Portable Bit Map.
    ASCII or binary format.
    Stores raster images formatted as plain text, representing each pixel as a 0 (white) or 1 (black).
    Developed in 1988 as part of the Pbmplus package.

Import and ExportImport and Export

  • Import["file.pbm"] imports a PBM file, returning an Image object.
  • Export["file.pbm",expr] exports an image, graphics, or any other expression as a raster image to PBM.
  • Export by default generates binary PBM files.
  • When exporting Wolfram Language graphics or arbitrary expressions to PBM, the resulting image has the same raster size as its displayed form.
  • Image objects are by default exported at their raster size.
  • Because PBM is a raster image format, all fonts are rasterized on export.
  • Import["file.pbm",elem] imports the specified element from a PBM file.
  • Import["file.pbm",{elem,suba,subb,}] imports a subelement.
  • Import["file.pbm",{{elem1,elem2,}}] imports multiple elements.
  • The import format can be specified with Import["file","PBM"] or Import["file",{"PBM",elem,}].
  • Export["file.pbm",expr,elem] creates a PBM file by treating expr as specifying element elem.
  • Export["file.pbm",{expr1,expr2,},{{elem1,elem2,}}] treats each as specifying the corresponding .
  • Export["file.pbm",expr,opt1->val1,] exports expr with the specified option elements taken to have the specified values.
  • Export["file.pbm",{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 PBM format.

Notebook InterfaceNotebook Interface


  • 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 grayscale values
    "Graphics"Graphics object representing an image
    "GrayLevels"array of normalized gray-level values
    "Image"raster image, given as an Image object
    "RGBColorArray"array of RGBColor objects
  • Import and Export by default use the element for PBM files.
  • Advanced Import elements:
  • "BitDepth"bits used to represent each color channel in the file
    "ColorSpace"color space of the image
    "DataType"data type used for storing pixel elements
    "ImageSize"raster dimensions


ExamplesExamplesopen allclose all

Basic Examples  (1)Basic Examples  (1)

This imports a PBM example file and renders it as Graphics:

Click for copyable input

Read meta-information elements and from this file:

Click for copyable input
Introduced in 1999
| Updated in 2012