Control the size and device characteristics Chrome uses to render your image.
How it works
The viewport is the visible area of the browser page. By default, Chrome renders pages in a 1920x1080 viewport. Use the viewport parameters to render responsive layouts at a specific size or emulate mobile, landscape, and touch behavior.
Parameters
Parameter
Type
Description
viewport_width
Integer
Set the viewport width in CSS pixels. Must be used with viewport_height. The maximum width is 6000.
viewport_height
Integer
Set the viewport height in CSS pixels. Must be used with viewport_width.
viewport_mobile
Boolean
Set to true to emulate a mobile viewport and apply the page’s mobile viewport behavior.
viewport_landscape
Boolean
Set to true to render the viewport in landscape orientation.
viewport_touch
Boolean
Set to true to enable touch support in the viewport.
The three Boolean parameters are optional and default to false. They can be used together, but they do not set the viewport dimensions. Use viewport_width and viewport_height to choose the exact layout size.
Setting viewport width and height
Both dimensions must be included when setting the viewport:
curl -X POST https://hcti.io/v1/image -u'UserID:APIKey'\--data-urlencodeurl="https://example.com"\--dataviewport_width=1200 \--dataviewport_height=630
Setting explicit dimensions disables automatic cropping and returns the area rendered inside the viewport. For HTML snippets that should be tightly cropped to their content, set the dimensions in CSS instead.
Emulating a mobile viewport
Combine a mobile-sized viewport with mobile emulation:
The viewport is Chrome’s virtual screen, measured in CSS pixels. It controls the page layout but does not necessarily determine the final image dimensions.
device_scale changes the output resolution without changing the CSS viewport size. A 1000x1000 viewport with device_scale: 1.5 produces a 1500x1500 image.
full_screen can produce an image taller than viewport_height by capturing content below the initial viewport.
selector crops the final image to a specific element rendered inside the configured viewport.
Automatic cropping controls the bounds of the final image after the page has been rendered.
Choose viewport dimensions that match the breakpoint you want to capture. The width determines which CSS media queries and responsive styles are applied.
Need help?
We’re always looking to improve this documentation. Please send us an email: support@htmlcsstoimage.com. We respond fast.