PNG (.png)

  • Import and Export fully support Version 1.2 of the PNG format.
  • Import and Export support Exif 2.3, IPTC 4.2, and XMP metadata standards.


    Registered MIME type: image/png
    PNG raster image format.
    Commonly used for graphics and photographic images on the web.
    PNG is an acronym for Portable Network Graphics.
    Binary format.
    Stores a single image.
    Stores color bitmaps at a resolution of 8 or 16 bits per channel.
    Grayscale images are represented at a depth of 1, 2, 4, 8, or 16 bits per pixel.
    Supports alpha channels for 8-bit and 16-bit RGB and grayscale images.
    Has support for color-reduction palettes using up to 256 8-bit RGB colors.
    Developed in 1995 as an open and patent-free alternative to the GIF format.
    Published as international standard ISO/IEC 15948:2003 and ISO/IEC 15948:2004.

Import and ExportImport and Export

  • Import["file.png"] imports a PNG file, returning an image.
  • Import["file.png",elem] imports the specified element from a PNG file.
  • The import format can be specified with Import["file","PNG"] or Import["file",{"PNG",elem,}].
  • Export["file.png",expr] exports an image, graphics, or any other expression as an image to a PNG file.
  • Image objects are by default exported at their full raster size. Graphics and other arbitrary expressions are exported using the same raster size as their displayed form.
  • See the reference pages for full general information on Import and Export.
  • ImportString and ExportString support the PNG format.

Notebook InterfaceNotebook Interface

  • In the notebook front end, Insert Picture and the Open menu allow the import of a PNG file into a cell.
  • Save Selection As exports the selected part of a notebook as a PNG file.


  • 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
    "Image"raster image, given as an Image object
    {"Thumbnail",size}thumbnail of a given size (default size = Small)
  • Import and Export by default use the "Image" element for PNG files.
  • Elements of PNG files using a color-reduction palette:
  • Advanced Import elements include:
  • "BitDepth"bits used to represent each color channel in the file
    "CameraTopOrientation"orientation of the camera when the picture was taken
  • the number of color channels used in the file
  • "ColorProfileData"embedded color profile, given as a ColorProfileData object
    "ColorSpace"color encoding used in the file
  • whether the flash was fired
  • "GeoPosition"latitude and longitude represented as a GeoPosition object
  • image creation date and time registered by GPS
  • "ImageSize"raster dimensions
    "RedEyeCorrection"whether a red-eye correction was performed
  • summary of the file
  • Metadata elements:
  • "Exif"formatted Exif (Exchange image file format)
    "IPTC"formatted IPTC (International Press Telecommunications Council)
    "XMP"formatted XMP (Extensible metadata platform)
  • Raw metadata, as stored in the file, can be imported using "RawExif", "RawXMP" and "RawIPTC" elements which are returned in an association.
  • All Exif and IPTC tags can be imported individually. Common tags include:
  • "ApertureValue"lens aperture
    "Artist"photographer or image creator
    "DateTime"image creation date and time
    "ExposureTime"exposure time, given in seconds
  • flash information: flash fired, red-eye correction, etc.
  • "FNumber"F number
    "FocalLength"actual focal length of the lens, given in millimeters
    "GPSAltitude"altitude of the GPS position
    "GPSLatitude"latitude of the GPS position
    "GPSLongitude"longitude of the GPS position
    "Make"manufacturer of the recording equipment
    "Model"model name or model number of the equipment
    "Software"name and version of the software or firmware of the camera or image input device used to generate the image


  • Import and Export option:
  • ImageSizeAutomaticoverall image size
    IncludeMetaInformationAllmetadata types to import and export
    "ImageTopOrientation"Automaticorientation of the image as stored in the file
  • Import option:
  • "TakeRows"{1,-1}rows to import
  • Export option:
  • "Comments"Nonetextual information
  • Supported "ColorSpace" settings are: "Grayscale" and "RGB". Using "ColorSpace"->Automatic, Export attempts to create a PNG file with the same color space.

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

Import a PNG file as an image:

Click for copyable input

Summary of an image:

Click for copyable input

Export an RGB image to PNG:

Click for copyable input
Introduced in 2003
| Updated in 2016