Width & Height Parameters

The width and height parameters control the viewport dimensions for capturing images.

Specifications

Width Parameter

PropertyValue
Typeinteger
RequiredNo
Default1440
Range1-5000
APIBoth HTML/CSS and Screenshot APIs

Height Parameter

PropertyValue
Typeinteger
RequiredNo
Default900
Range1-5000
APIBoth HTML/CSS and Screenshot APIs

Description

These parameters determine:

  • The viewport size for rendering content
  • The dimensions of the output image (unless fullpage is true)
  • The responsive breakpoint for the content

When using DPI values greater than 1, the actual rendered dimensions will be multiplied by the DPI value. For example:

  • With width=1920 and DPI=2, the final image will be 3840px wide
  • With height=1080 and DPI=2, the final image will be 2160px tall

To maintain specific output dimensions when using higher DPI:

  • Either divide your desired dimensions by the DPI value
  • Or omit width/height to let the image scale naturally with DPI

See the DPI parameter documentation for more details.

Examples

Basic Dimensions

{
    "html": "<div>Responsive Content</div>",
    "width": 1920,
    "height": 1080
}

Mobile Viewport

{
    "url": "https://example.com",
    "width": 375,
    "height": 667
}

Tablet Viewport with Custom Height

{
    "html": "<div>Tablet Content</div>",
    "width": 768,
    "height": 1024,
    "dpi": 2
}

Larger dimensions increase processing time and memory usage. For high-resolution images, consider using a smaller viewport with a higher DPI value instead of very large dimensions.

Common Viewport Sizes

Here are some common viewport sizes you might want to use:

DeviceWidthHeight
Desktop HD19201080
Desktop1440900
Laptop1366768
Tablet7681024
Mobile375667

When using responsive designs, test your content at multiple viewport sizes before locking in a render width.

Common values

  • 1200x630 - Open Graph image, Twitter, LinkedIn share previews.
  • 1080x1080 - Instagram square post.
  • 1280x720 - YouTube thumbnail.
  • 1920x1080 - Desktop screenshot.
  • 375x667 - Mobile screenshot at iPhone SE viewport.
  • 1240x1754 - A4 portrait at 150 DPI, useful for invoices and certificates.

When to use

Set width and height whenever you need a specific output size, especially for social platforms with rigid spec requirements. Leave them at the defaults (1440x900) for general-purpose renders. For full-page captures, set width to the device width and use fullpage to let the height grow.

Common mistakes

  • Forgetting that DPI multiplies dimensions. A width: 1200 with dpi: 2 produces a 2400px file. Either divide your target by the DPI or omit width and let DPI scale.
  • Setting unusually large dimensions. A 5000x5000 render eats memory and time. Prefer a smaller viewport with higher DPI when you want a sharp file.

See also: twitter-embed example, product-card example, invoice-receipt example, and the getting started guide.