Driver FixRecommendedSound, Wi-Fi or graphics acting up? Check drivers firstFind missing or outdated drivers fast.Check DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk4 min

How to Capture a Webpage Screenshot at an Exact Viewport Size

Control a webpage screenshot’s viewport with Chrome Headless or Playwright, then verify the saved image dimensions when exact bitmap pixels matter.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set the browser viewport to the width and height you need, then capture the visible page. For a quick command-line capture, use Chrome Headless with --window-size; for repeatable automation, set Playwright’s viewport before navigating. If the required deliverable is an image file with exactly those pixel dimensions, check the saved image: viewport size and output pixel size can differ when device-pixel scaling is involved.

Choose what “exact size” means

A viewport is the browser’s visible content area, measured in CSS pixels. The screenshot file has bitmap dimensions measured in image pixels. Those numbers match when the capture uses one output pixel per CSS pixel; device-pixel scaling can make the bitmap larger. A full-page screenshot is different again: it extends to include the scrollable document, rather than only the visible viewport.

As an Amazon Associate I earn from qualifying purchases.

  • Exact viewport: control the browser’s visible width and height.
  • Exact bitmap: require a particular number of pixels in the resulting image, and inspect the file dimensions to confirm.
  • Full page: capture the scrollable document; the image height can exceed the viewport height.

Fast command-line capture with Chrome Headless

Chrome Headless documents --screenshot with --window-size=WIDTH,HEIGHT. Replace the example dimensions and URL as needed:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
chrome --headless --screenshot --window-size=412,892 https://developer.chrome.com/

The screenshot is saved in the current working directory. The documented example uses 412 by 892 as a window-size argument; it is illustrative, not a guarantee that every platform and configuration will produce a bitmap of exactly 412 by 892 pixels. If exact file dimensions matter, inspect the saved image and adjust for the browser and device scale in use. Chrome Headless documentation

#1 Best Overall
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
  • A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents

Repeatable captures with Playwright

Set the viewport before navigation, then capture the page. Playwright recommends this order because some sites do not expect a phone-sized viewport to be changed after the page has loaded.

const { chromium } = require('playwright');

(async () => {
  const browser = await chromium.launch({ headless: true });
  const page = await browser.newPage();
  await page.setViewportSize({ width: 640, height: 480 });
  await page.goto('https://example.com');
  await page.screenshot({ path: 'screenshot.png', fullPage: false, scale: 'css' });
  await browser.close();
})();

Install Playwright in your project before running the script. The scale setting controls the relationship between CSS pixels and output pixels:

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB | 1920×1080 LED Monitor, 4ms GtG, Adaptive Sync, HDMI 1.4, Tilt Adjust, Low Blue Light, 4yr Advance Replacement Warranty
  • CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
  • 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
  • SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
  • INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
  • THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
  • scale: 'css' produces one image pixel per CSS pixel.
  • scale: 'device' produces one image pixel per device pixel, so a high-DPI capture may be larger than the CSS viewport dimensions.

Use fullPage: false for the visible viewport. Set fullPage: true only when you want the entire scrollable document, which changes the image height. Playwright screenshot documentation

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use Chrome DevTools Protocol for lower-level control

If you are building your own browser-control workflow, Chrome DevTools Protocol provides Page.captureScreenshot, including a clip option, and commands for querying CSS layout and visual viewport metrics. This route offers lower-level capture control, but requires managing the protocol and its parameters rather than using a higher-level screenshot call. Chrome DevTools Protocol Page domain

Rank #3
Dell 24 Monitor - SE2426H - 23.8-inch FHD (1920x1080) 144Hz 1ms Display, in-Plane Switching (IPS) Technology, AMD FreeSync™, TÜV 3-Star 2X HDMI, Tilt
  • Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
  • Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
  • Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
  • In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
  • Ultra-thin bezels: Maximize your viewing experience with thin bezels.

Keep captures comparable

Matching viewport dimensions alone does not ensure pixel-identical results across machines. Playwright notes that rendering can vary with the host operating system, browser version, settings, hardware, power source, headless mode, and other factors. For visual comparisons, keep those conditions and the device scale consistent, and use the same capture mode. Playwright visual comparison guidance

Troubleshoot size and capture problems

  • The image is larger than the requested viewport: check whether device-pixel scaling is in use. In Playwright, choose scale: 'css' when you want one output pixel per CSS pixel.
  • The image is taller than the viewport: check whether full-page capture is enabled. Use a viewport screenshot when only the visible area is wanted.
  • The layout looks like a desktop page at phone dimensions: set the viewport before navigation, not after the site has loaded.
  • The bitmap does not have the required W×H dimensions: inspect the actual output file dimensions and verify the browser’s device scale and capture settings. Do not assume a requested window size guarantees a particular bitmap on every platform.
  • Two captures differ despite equal dimensions: align the operating system, browser version, settings, hardware conditions, headless mode, and device scale before comparing them.

Or skip the browser setup

ScreenshotNeo takes a screenshot or PDF with one GET request. Example using cURL:

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor | 100Hz, Game Mode, Advanced Eye Comfort, HDMI and D-sub Ports (LS27D366GANXZA)
  • CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
  • SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
  • MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
  • KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
  • INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. Cookie banners are accepted and removed before capture, along with known newsletter popups and chat widgets; each cleanup step can be turned off. Bot checks, blank pages, timeouts and failed loads are not billed, and cache hits cost nothing. An MCP server lets AI agents use screenshot tools. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots. Visit ScreenshotNeo for details, or sign up free.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Frequently Asked Questions

Should I use CSS scale or device scale in Playwright?

Use CSS scale for one output pixel per CSS pixel. Device scale follows device pixels and may produce a larger image.

Does an exact viewport guarantee identical screenshots on another computer?

No. Browser and host environment differences can change rendering even when viewport dimensions match.

Best Value
Sale
Sceptre New 22-Inch Gaming Monitor, FHD 1080p, Up to 144Hz, HDMI, DisplayPort, Built-in Speakers, Machine Black (E225W-FW144 Series, 2026)
  • 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
  • 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
  • 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.