How to capture a Chromium screenshot at 2x device scale factor
Set Chromium’s device scale factor to 2 in DevTools or CDP, capture the viewport or full page, and verify the saved image dimensions.
To capture a Chromium screenshot at 2×, set the device scale factor (DPR) to 2 before capturing. In DevTools, enable the DPR control and choose 2; for repeatable automation, use the Chrome DevTools Protocol (CDP) method Emulation.setDeviceMetricsOverride, then call Page.captureScreenshot. Choose viewport capture for the visible area or full-page capture when you need content beyond it.
What 2× device scale factor means
DPR is the ratio between device pixels and CSS pixels. At DPR 2, a 400 CSS-pixel-wide viewport is nominally rendered at 800 device pixels wide. The height scales the same way. Confirm the actual dimensions of the saved image: capture scope, browser behavior, and image handling can affect what you receive.
A DPR override controls rendering scale; it does not by itself emulate a particular phone. Mobile emulation also changes behavior such as viewport-meta handling. DevTools Device Mode approximates a mobile device and does not run the page on physical hardware. Validate on a real device when device-specific behavior matters.
Capture at 2× with Chrome DevTools
- Open the page in Chromium or Chrome, then open DevTools.
- Toggle the device toolbar.
- Open More options > Add device pixel ratio.
- Choose 2 in the DPR selector above the emulated viewport.
- Set the viewport width and height in CSS pixels. Choose mobile emulation if you want its associated mobile behavior, rather than only a higher pixel density.
- Open More options > Capture screenshot for the visible viewport, or choose Capture a full size screenshot for the full page.
The viewport and full-size actions have different scopes. A viewport screenshot excludes content outside the visible area. Use the full-size action for a long page, then inspect the downloaded image dimensions to verify the result.
Automate a 2× screenshot with CDP
Attach a CDP client to the target page, set the emulated metrics, and capture the image. The following is the protocol command sequence; send both commands to the same page session, in order:
{
"method": "Emulation.setDeviceMetricsOverride",
"params": {
"width": 400,
"height": 800,
"deviceScaleFactor": 2,
"mobile": false
}
}
{
"method": "Page.captureScreenshot",
"params": {
"format": "png"
}
}
The width and height are CSS viewport dimensions. With the settings above, the viewport’s nominal raster size is 800 × 1600 device pixels. The screenshot command returns image data encoded as a base64 string; decode it and write the bytes to a file. The snippet shows the protocol payloads rather than a particular client library because CDP transport and session setup differ between clients.
For mobile-oriented emulation, set mobile to true and use the viewport dimensions appropriate to the target layout. A DPR override alone does not reproduce all mobile behavior.
Viewport or beyond-viewport capture
Page.captureScreenshot accepts PNG, JPEG, and WebP formats. Its captureBeyondViewport parameter controls capture beyond the viewport and defaults to false in the current protocol reference. For full-page output, set the beyond-viewport behavior as appropriate for your target and client, or use DevTools’ full-size screenshot command. Check the resulting image dimensions because a successful command does not by itself prove that the full document was captured.
Use Protocol Monitor or the DevTools console
For a manual protocol experiment, Chromium’s Protocol Monitor or DevTools console can send CDP commands. Issue the metrics override before the screenshot command. For production automation, use a CDP client that attaches to the correct page target and waits for each response before sending the next command.
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server for developers. It accepts one GET request with a URL and returns an image or PDF. The API parameters used by other screenshot services also work, which can make switching easier. See the ScreenshotNeo API documentation for the available options.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Cookie and consent banners, newsletter popups, and chat widgets are removed before capture, and each cleanup step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing; response headers report the page verdict and billing status. AI agents can use its MCP server tools to take screenshots, get page information, and capture PDFs. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. All features are available on every plan. Learn more at ScreenshotNeo.
Sign up for ScreenshotNeo and get 1,000 free screenshots a month, with no card.
Common problems and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| The image is not twice the CSS viewport dimensions. | The DPR override was not applied to the target page, or the screenshot’s scope differs from the viewport. | Send Emulation.setDeviceMetricsOverride to the page session before capture. Check the returned image’s pixel dimensions and distinguish viewport output from full-page output. |
| The capture looks desktop-sized even though DPR is 2. | DPR changes pixel density, not the page’s responsive layout by itself. | Set the CSS viewport dimensions you want. Enable mobile emulation if you need mobile viewport behavior. |
| The page is cut off. | A viewport capture only includes visible content, or beyond-viewport capture was not enabled. | Use DevTools’ full-size screenshot action or configure CDP beyond-viewport capture. Verify the output dimensions. |
| CDP returns an error or captures the wrong tab. | The command was sent to the browser target instead of the page session, or the client issued commands before attaching to the intended target. | Attach to the correct page target, send the metrics override through that page’s session, wait for its response, then capture. |
| Mobile layout differs from a real phone. | Device Mode is an approximation and does not run on the target hardware. | Test on the physical device when rendering or behavior depends on device-specific features. |
Performance, reliability, and output considerations
- More pixels mean more image data. Doubling both dimensions produces about four times as many pixels as a 1× capture of the same CSS viewport. PNG, JPEG, and WebP can yield different file sizes; choose the format that suits your workflow.
- Full-page captures can be much larger. Long documents require more pixels and may take longer to render and encode. Capture only the viewport when offscreen content is unnecessary.
- Make runs repeatable. Apply the metrics override before each capture and keep viewport dimensions, mobile setting, format, and scope consistent across runs.
- Wait for page readiness. A screenshot command can capture a page before asynchronous content or images finish loading. In your automation, wait for the content your use case requires before capture.
- Verify artifacts. Check that the file decodes and inspect its pixel dimensions. A successful protocol response does not guarantee that a page rendered completely or that the intended region was captured.
FAQ
Does DPR 2 make the CSS viewport twice as wide?
No. The width and height you set are CSS viewport dimensions. DPR 2 scales the rendered pixel dimensions by two in each direction.
Can I capture at 2× without mobile emulation?
Yes. Set deviceScaleFactor to 2 and mobile to false if you want a higher-density desktop-style rendering. Use mobile emulation only when you want its additional behavior.
Which image formats can CDP capture?
Page.captureScreenshot supports PNG, JPEG, and WebP. Pick a format based on your downstream quality and file-size needs.
Will Device Mode prove how the page looks on a phone?
No. It approximates device behavior. Use the actual hardware for validation where device-specific rendering is important.


