This is documentation for Mathematica 6, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
Mathematica Import/Export Format

MGF (.mgf)

Wolfram Mathematica MGF bitmap format.
Used by the Mathematica 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["file.mgf"] imports an MGF file, returning a graphics object.
  • Export["file.mgf", expr] exports graphics or any other expression as an MGF raster image.
  • Import["file.mgf"] returns an expression of the form Graphics[Raster[data], opts], where data is an array of color values.
  • Export["file.mgf", expr] creates an MGF image with the same image size as the displayed form of expr.
  • 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 reference pages for full general information on Import and Export.
"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:
"Cell"notebook Cell expression representing the image
"Graphics"raster image given as a Graphics object
  • Import and Export by default use the "Graphics"element for MGF files.
  • General option:
ImageSizeAutomaticoverall image size
Import an MGF file as graphics:
In[1]:=
Click for copyable input
Out[1]=
 
Export arbitrary graphics to the MGF format:
In[1]:=
Click for copyable input
Out[1]=