Rasterize
✖
Rasterize
Details and Options



- The expression expr can be graphics, text, a cell, a notebook object or any other expression.
- Rasterize[nb] gives a rasterized version of the complete content associated with the notebook object nb.
- Possible basic elements that can be returned by Rasterize include:
-
"BoundingBox" bounding box information for the raster "Data" the array of pixel values in the raster "Graphics" a graphics object representing the raster "Image" an image object representing the raster "RasterSize" pixel width and height of the raster "Regions" regions specified by Annotation constructs - Rasterize[expr] is equivalent to Rasterize[expr,"Image"] and displays in a notebook in a way that approximates the unrasterized display of expr, with the same image size.
- An expression displayed at a given size at the default screen resolution res will result in a raster of dimension
.
- The following options for Rasterize can be given:
-
Background Automatic background to use BaselinePosition Automatic how to align with a surrounding text baseline ImageFormattingWidth $ImageFormattingWidth wrapping width for expressions to be rasterized ImageResolution $ImageResolution image resolution in dpi for rasterization ImageSize Automatic final displayed image size in printer's points RasterSize Automatic raster size in pixels for rasterization - RasterSize and ImageResolution determine the coarseness of rasterization; ImageSize determines the size at which the final image will be displayed.
- If there is an explicit setting for RasterSize, it overrides any explicit setting for ImageResolution.
- When the settings for RasterSize or ImageResolution are small, the graphic will appear coarse, and text may be illegible. There may also be artifacts associated with aliasing.
- Settings for ImageSize and Background in Rasterize override any settings for those options in expr.
- Background->None yields a raster with a transparent background.
- If no explicit size or resolution option settings are given, Rasterize[expr,…] will rasterize expr at the size and resolution it would normally be displayed in a notebook.
- Rasterize[expr,"RasterSize"] yields {w,h}, where w is the overall width in pixels of the raster, and h is its overall height.
- Rasterize[expr,"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 expr from the bottom of its bounding box.
- Images 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[expr,"BoundingBox"] can depend on details of font metrics, which generally differ between different computer systems.
- Rasterize[expr,"Regions"] gives a list of rules of the form {{a1,type1}->reg1,{a2,type2}->reg2,…}, where each rule {ai,typei}->regi is associated with an annotation of the form Annotation[expr,ai,typei] in expr, or with an object that is automatically recognized as an annotation, such as a Hyperlink or Tooltip. The regi give pixel positions in the form {{xmin,ymin},{xmax,ymax}}, where y coordinates run from top to bottom, mirroring the coords attribute of HTML.
Examples
open allclose allBasic Examples (3)Summary of the most common use cases
Make a 15-pixel-wide rasterization of an image of a disk:

https://wolfram.com/xid/0bim62ru-g9h71z

Make a 75-pixel-wide rasterization of text, and display it 200 pixels wide:

https://wolfram.com/xid/0bim62ru-glmp4t

Make a 36 dpi rasterization of a 3D graphic with light yellow background:

https://wolfram.com/xid/0bim62ru-fuqd7a

Scope (11)Survey of the scope of standard use cases
Convert any Wolfram Language expression into a raster graphic:

https://wolfram.com/xid/0bim62ru-b0hxtp

The default output is a raster graphic:

https://wolfram.com/xid/0bim62ru-ddom0r

Get the bounding box information:

https://wolfram.com/xid/0bim62ru-60rfr

Get the array of pixel values for the raster:

https://wolfram.com/xid/0bim62ru-ia3cs


https://wolfram.com/xid/0bim62ru-bxrreb


https://wolfram.com/xid/0bim62ru-cm7kd9

Get the pixel dimensions of the raster:

https://wolfram.com/xid/0bim62ru-cgl3wn

Get both the raster graphic and its pixel dimensions:

https://wolfram.com/xid/0bim62ru-3pnuf5

Define regions using Annotation:

https://wolfram.com/xid/0bim62ru-n9nzkp


https://wolfram.com/xid/0bim62ru-eu3kg4

Display the regions using rectangles:

https://wolfram.com/xid/0bim62ru-geyxxn


https://wolfram.com/xid/0bim62ru-hezlv8


https://wolfram.com/xid/0bim62ru-pwond


https://wolfram.com/xid/0bim62ru-bjzuzt

RasterSize overrides ImageResolution:

https://wolfram.com/xid/0bim62ru-dpxsw4

Options (12)Common values & functionality for each option
Background (2)

https://wolfram.com/xid/0bim62ru-9mhsy

By default, the background is opaque white:

https://wolfram.com/xid/0bim62ru-hhh5x

Make the background transparent by setting Background->None:

https://wolfram.com/xid/0bim62ru-luifgj

ImageFormattingWidth (2)
ImageResolution (3)
The default resolution is determined by the current display settings:

https://wolfram.com/xid/0bim62ru-jcg32m


Use ImageResolution to specify the desired resolution:

https://wolfram.com/xid/0bim62ru-vn2xjr



https://wolfram.com/xid/0bim62ru-4uct2b

Image resolution affects the raster size but not the display size of the expression:

https://wolfram.com/xid/0bim62ru-l2x0ds

Raster size at different resolutions:

https://wolfram.com/xid/0bim62ru-bw12i7

Display size at different resolutions:

https://wolfram.com/xid/0bim62ru-tg5zle

RasterSize overrides ImageResolution:

https://wolfram.com/xid/0bim62ru-srula7

Low-resolution rasterization with the automatic raster size:

https://wolfram.com/xid/0bim62ru-je9vh7

ImageSize (2)
By default, rasterized expressions are returned at their original display size:

https://wolfram.com/xid/0bim62ru-sth23n


https://wolfram.com/xid/0bim62ru-bvqkop

Use the ImageSize option to set a specific display size:

https://wolfram.com/xid/0bim62ru-6wr68v

The ImageSize option overrides any previous settings in the expression being rasterized:

https://wolfram.com/xid/0bim62ru-j39ir4


https://wolfram.com/xid/0bim62ru-kq0gpu


https://wolfram.com/xid/0bim62ru-32j9e5

If an expression does not have a scalable display size, ImageSize is only setting the final display size:

https://wolfram.com/xid/0bim62ru-uez3ng


https://wolfram.com/xid/0bim62ru-46lqbr

RasterSize (3)
The default raster size is determined by the display size of the expression and the resolution settings:

https://wolfram.com/xid/0bim62ru-b6ze4u


Use RasterSizew to specify an explicit image width:

https://wolfram.com/xid/0bim62ru-1grzgu


Use RasterSize{w,h} to specify both width and height:

https://wolfram.com/xid/0bim62ru-w26v4j


Set different raster sizes in pixels:

https://wolfram.com/xid/0bim62ru-f69dsk

RasterSize overrides ImageResolution. Use the default RasterSize:

https://wolfram.com/xid/0bim62ru-1glw0x


https://wolfram.com/xid/0bim62ru-bt7846

Specify the RasterSize:

https://wolfram.com/xid/0bim62ru-p6v5q3


https://wolfram.com/xid/0bim62ru-523miv

Applications (3)Sample problems that can be solved with this function
Image of the first 1000 letters from the US Constitution:

https://wolfram.com/xid/0bim62ru-dzmeli

https://wolfram.com/xid/0bim62ru-dp7pxx

Thumbnail of a Wolfram System notebook:

https://wolfram.com/xid/0bim62ru-b9b2p4

https://wolfram.com/xid/0bim62ru-jd4

Rasterize a line segment with grid lines:

https://wolfram.com/xid/0bim62ru-bxalxl

https://wolfram.com/xid/0bim62ru-ylizg


https://wolfram.com/xid/0bim62ru-kdl042

Properties & Relations (2)Properties of the function, and connections to other functions
Rasterizing a graphic with a custom ImageSize option works by changing the graphic's ImageSize, not by magnifying the graphic:

https://wolfram.com/xid/0bim62ru-d5a9v

https://wolfram.com/xid/0bim62ru-bwpfam

A graphic embedded in a non-graphical construct will magnify instead:

https://wolfram.com/xid/0bim62ru-jd9am

Rasterizing a Cell expression displays the cell's contents as the Wolfram System front end would:

https://wolfram.com/xid/0bim62ru-5l9hqb

Properties of the cell that affect the contents will be displayed:

https://wolfram.com/xid/0bim62ru-12hmpq

Properties that only affect margins or cell-level decorations will not be displayed:

https://wolfram.com/xid/0bim62ru-o0tbrx

Possible Issues (1)Common pitfalls and unexpected behavior
Because ImageSize is in points, it may not correspond to the pixel dimensions of the resulting image:

https://wolfram.com/xid/0bim62ru-hxsk2h

To specify the pixel dimensions, use RasterSize:

https://wolfram.com/xid/0bim62ru-pwbszz

Interactive Examples (1)Examples with interactive outputs
Wolfram Research (2007), Rasterize, Wolfram Language function, https://reference.wolfram.com/language/ref/Rasterize.html (updated 2020).
Text
Wolfram Research (2007), Rasterize, Wolfram Language function, https://reference.wolfram.com/language/ref/Rasterize.html (updated 2020).
Wolfram Research (2007), Rasterize, Wolfram Language function, https://reference.wolfram.com/language/ref/Rasterize.html (updated 2020).
CMS
Wolfram Language. 2007. "Rasterize." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/Rasterize.html.
Wolfram Language. 2007. "Rasterize." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2020. https://reference.wolfram.com/language/ref/Rasterize.html.
APA
Wolfram Language. (2007). Rasterize. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Rasterize.html
Wolfram Language. (2007). Rasterize. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Rasterize.html
BibTeX
@misc{reference.wolfram_2025_rasterize, author="Wolfram Research", title="{Rasterize}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/Rasterize.html}", note=[Accessed: 08-June-2025
]}
BibLaTeX
@online{reference.wolfram_2025_rasterize, organization={Wolfram Research}, title={Rasterize}, year={2020}, url={https://reference.wolfram.com/language/ref/Rasterize.html}, note=[Accessed: 08-June-2025
]}