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

Rasterize

Rasterize[g]
returns a rasterized graphic of g.
Rasterize[g, elem]
gives the element elem associated with the rasterized form of g.
  • The expression g need not explicitly be a graphic, but can be text, a cell, or any expression.
  • Possible basic elements include:
"BoundingBox"bounding box information for the raster
"Data"the array of pixel values in the raster
"Graphics"a graphics object representing the raster
"RasterSize"pixel width and height of the raster
"Regions"regions specified by Annotation constructs
"RGBColor"array of RGBColor objects
  • Rasterize[g] is equivalent to Rasterize[g, "Graphics"], and displays in a notebook in a way that approximates the unrasterized display of g, with the same image size.
  • The following options for Rasterize can be given:
BackgroundAutomaticbackground to use
BaselinePositionAutomatichow to align with a surrounding text baseline
ImageResolutionAutomaticimage resolution in dpi for rasterization
ImageSizeAutomaticfinal displayed image size in printer's points
RasterSizeAutomaticraster size in pixels for rasterization
  • When the settings for RasterSize or ImageResolution are small, the graph will appear coarse, and text may be illegible. There may also be artifacts associated with aliasing.
  • If no explicit size or resolution option settings are given, Rasterize[g, ...] will rasterize g at the size and resolution it would normally be displayed in a notebook.
  • Rasterize[g, "RasterSize"] yields {w, h}, where w is the overall width in pixels of the raster, and h is its overall height.
  • Rasterize[g, "BoundingBox"] yields {w, h, dh}, where w is the overall width, h is the overall height and dh is the offset of the baseline of the contents of g from the bottom of its bounding box.
  • Rasters generated by Rasterize can vary slightly from one computer system to another, mainly as a result of different fonts and anti-aliasing procedures.
  • The results from Rasterize[g, "BoundingBox"] can depend on details of font metrics, which generally differ between different computer systems.
  • Rasterize[g, "Regions"] gives a list of rules of the form {a1->reg1, a2->reg2, ...}, where each rule ai->regi is associated with an annotation of the form Annotation[expr, ai, "Region"] in g. The regi give pixel positions in the form {{xmin, ymin}, {xmax, ymax}}, where y coordinates run from bottom to top, as in Graphics.
Make a 15-pixel-wide rasterization of an image of a disk:
In[1]:=
Click for copyable input
Out[1]=
 
Make a 75-pixel-wide rasterization of text, and display it 200 pixels wide:
In[1]:=
Click for copyable input
Out[1]=
 
Make a 36 dpi rasterization of a 3D graphic, with light yellow background:
In[1]:=
Click for copyable input
Out[1]=
New in 6