Documentation
Width & Height Parameters
The width
and height
parameters control the viewport dimensions for capturing images.
Specifications
Width Parameter
Property | Value |
---|---|
Type | integer |
Required | No |
Default | 1440 |
Range | 1-5000 |
API | Both HTML/CSS and Screenshot APIs |
Height Parameter
Property | Value |
---|---|
Type | integer |
Required | No |
Default | 900 |
Range | 1-5000 |
API | Both 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:
Device | Width | Height |
---|---|---|
Desktop HD | 1920 | 1080 |
Desktop | 1440 | 900 |
Laptop | 1366 | 768 |
Tablet | 768 | 1024 |
Mobile | 375 | 667 |
When using responsive designs, make sure to test your content at different viewport sizes to ensure it renders correctly.