DPI Parameter

The dpi parameter (Device Pixel Ratio) controls the resolution of the generated image.

Specifications

PropertyValue
Typeinteger
RequiredNo
Default1 (Screenshot API), 2 (HTML API)
Range1-4
APIBoth HTML/CSS and Screenshot APIs

Description

The DPI parameter:

  • Controls the image resolution
  • Affects the final image size
  • Impacts processing time and memory usage
  • Determines the clarity of text and graphics

Higher DPI values significantly increase processing time and memory usage. For most use cases, a DPI of 1 or 2 provides sufficient quality.

When using DPI values greater than 1, remember that the actual rendered dimensions will be multiplied by the DPI value. For example, a canvas with width=800 and DPI=2 will be rendered at 1600px wide. If you specify width and height parameters, you should either:

  • Increase your dimensions proportionally with DPI (e.g., double them for DPI=2)
  • Or omit width/height to let the image scale naturally with DPI

Examples

Basic Screenshot (Default DPI)

{
    "url": "https://example.com"
}

High Resolution HTML Capture

{
    "html": "<div>High Quality Text</div>",
    "dpi": 2
}

Maximum Quality Screenshot

{
    "url": "https://example.com",
    "dpi": 4,
    "webhook_url": "https://your-domain.com/webhook"
}

DPI Value Guide

DPIUse CaseNotes
1Quick screenshots, previewsFastest processing, smallest file size
2Standard quality, most use casesGood balance of quality and performance
3High quality, printingLarger files, slower processing
4Maximum qualityVery large files, significantly slower

When using DPI values of 3 or 4:

  • Always use the webhook_url parameter
  • Expect longer processing times
  • Be prepared for larger file sizes

Best Practices

  1. Choose the Right DPI

    • Use DPI 1 for thumbnails and previews
    • Use DPI 2 for standard web use
    • Use DPI 3-4 only when high resolution is required
  2. Optimize Performance

    • Combine with appropriate viewport dimensions
    • Use webhooks for high DPI captures
    • Consider file size requirements
  3. Testing

    • Test different DPI values with your content
    • Check file sizes and quality
    • Monitor processing times

The HTML API defaults to DPI 2 for better text rendering, while the Screenshot API defaults to DPI 1 for faster processing of web pages.