Next / Previous / Contents / Shipman's homepage

11.3. Scaling a figure

When sizing a figure for presentation, there are two different areas involved:

If one dimension of the image is smaller than that dimension of the viewport, the result will be empty space around the figure. But what if the viewport is smaller than the image? In print presentation, the image will be cropped; but in Web presentation the image will not be cropped.

In general there are six different attributes of imagedata that affect scaling:

contentwidth and contentdepth

These attributes set the desired image size. The attribute value must be a number, optionally followed by one of the dimension codes px (pixels, the default), pt (points), cm (centimeters), mm (millimeters), pc (picas), in (inches), em (ems), or % (percent, relative to the page width for horizontal dimensions).

For example, if you want the image to be 125mm×75mm, use:

    <imagedata contentwidth='125mm' contentdepth='75mm' .../>

You need only specify one of these two attributes; if only one dimension is specified, the other dimension will be scaled to preserve the aspect ratio (ratio of height to width).

width and depth

These attributes size the viewport. If you specify the width as a percentage (%), it will be treated as a percentage of the available page width.


Resizes the graphic as a percentage of the original; omit the % symbol from the attribute value. For example, to render a graphic half-size, use scale='50'.


If you specify scalefit='1', the graphic will be scaled to fit the available area—either the graphic size or the viewport size, whichever is filled first. If you specified no other sizing attributes, the graphic will be scaled to fit the page width.