MGF (.mgf)

Background & Context

    • Wolfram System MGF bitmap format.
    • Used by the Wolfram System user interface for storing raster images.
    • MGF is an acronym for Mathematica Graphics Format.
    • Binary format.
    • Stores a single image as an RGB raster at a resolution of 8 bits per color channel.

Import & Export

  • Import["file.mgf"] imports an MGF file and returns an image.
  • Export["file.mgf",expr] exports an image, graphics, or any other expression as an MGF raster image.
  • When exporting Wolfram Language graphics or arbitrary expressions to MGF, the resulting image has the same raster size as its displayed form.
  • Image objects are by default exported at their raster size.
  • Because MGF is a raster image format, all fonts are rasterized on export.
  • Import["file.mgf",elem] imports the specified element from an MGF file.
  • Import["file.mgf",{elem,suba,subb,}] imports a subelement.
  • Import["file.mgf",{{elem1,elem2,}}] imports multiple elements.
  • The import format can be specified with Import["file", "MGF"] or Import["file",{"MGF",elem,}].
  • Export["file.mgf",expr,elem] creates an MGF file by treating expr as specifying element elem.
  • Export["file.mgf",{expr1,expr2,},{{elem1,elem2,}}] treats each expri as specifying the corresponding elemi.
  • Export["file.mgf",expr,opt1->val1,] exports expr with the specified option elements taken to have the specified values.
  • Export["file.mgf",{elem1->expr1,elem2->expr2,},"Rules"] uses rules to specify the elements to be exported.
  • See the following reference pages for full general information:
  • Import, Exportimport from or export to a file
    CloudImport, CloudExportimport from or export to a cloud object
    ImportString, ExportStringimport from or export to a string
    ImportByteArray, ExportByteArrayimport from or export to a byte array

Import Elements

  • General Import elements:
  • "Elements" list of elements and options available in this file
    "Summary"summary of the file
    "Rules"list of rules for all available elements
  • Data representation elements:
  • "Cell"notebook Cell expression representing the image
    "Graphics"raster image given as a Graphics object
    "Image"image object
  • Import and Export by default use the "Image" element for MGF files.



Basic Examples  (1)

Export arbitrary graphics to the MGF format:

Import the new MGF file as graphics: