Mathematica > Data Manipulation > Importing and Exporting > PNM (.pnm) >

PNM (.pnm)

MIME types: image/x-portable-anymap, image/pbm
PNM raster image format.
Generic format of the Portable family of image formats.
Includes the PBM (monochrome), PGM (gray-level) and PPM (RGB color) image formats.
Native format of the Netpbm graphics software package.
Primarily used as an intermediate file format on Unix systems.
PNM is an acronym derived from Portable Any Map.
ASCII or binary format.
Stores raster images formatted as plain text, representing each pixel as a color value.
  • Export creates binary PNM files.
  • If multiple images are present in a PNM file, Import returns the first of the images.
  • Export exports an image, graphics, or any other expression as a raster image to PNM.
  • Export by default generates binary PNM files.
  • When exporting Mathematica graphics or arbitrary expressions to PNM, the resulting image has the same raster size as its displayed form.
  • Image objects are by default exported at their raster size.
  • Because PNM is a raster image format, all fonts are rasterized on export.
  • Import imports the specified element from a PNM file.
  • Import imports multiple elements.
  • Export creates a PNM file by treating expr as specifying element elem.
  • Export treats each as specifying the corresponding .
  • Export exports expr with the specified option elements taken to have the specified values.
  • Export uses rules to specify the elements to be exported.
  • See the reference pages for full general information on Import and Export.
  • In the notebook front end, Insert ► Picture and the Open menu allow import of a PNM file into a cell.
  • Save Selection As exports the selected part of a notebook as a PNM file.
"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, given as an Image object
"RGBColorArray"array of RGBColor objects
"ImageSize"raster dimensions
  • General options:
ImageSizeAutomaticoverall image size
"DataType"Automaticdata type used for storing pixel elements
"ImageTopOrientation"Toporientation of the exported image
  • Detailed property:
"ColorSpace"Automaticcolor space of the image
Import a sample PNM file as an image:
Read the image size element from the file:
Show all available import elements:
Import a sample PNM file as an image:
In[1]:=
Click for copyable input
Out[1]=
Read the image size element from the file:
In[2]:=
Click for copyable input
Out[2]=
Show all available import elements:
In[3]:=
Click for copyable input
Out[3]=
Ask a question about this page  |  Suggest an improvement  |  Leave a message for the team
Format:   HTML  |  CDF