October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Set the Device Scale Factor for Sharp Puppeteer Screenshots

Set Puppeteer’s deviceScaleFactor in the viewport before navigation. Learn how it differs from Sharp resizing and how to troubleshoot screenshot dimensions.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

Set Puppeteer’s deviceScaleFactor in page.setViewport() before navigating, then capture the page with page.screenshot(). This controls the device scale used to render the page; Sharp’s resize() changes the image after capture. They solve different problems and can be used together.

Set Puppeteer’s device scale factor before navigation

In Node.js Puppeteer, provide the CSS viewport width and height and the desired deviceScaleFactor to page.setViewport(). The documented default scale factor is 1. A value of 2 emulates a device scale factor of 2; the resulting pixel dimensions depend on the capture area and settings, so inspect the image when exact dimensions matter.

const puppeteer = require('puppeteer');

async function capture(url) {
  const browser = await puppeteer.launch();

  try {
    const page = await browser.newPage();
    await page.setViewport({
      width: 640,
      height: 480,
      deviceScaleFactor: 2,
    });

    await page.goto(url);
    const screenshot = await page.screenshot({ path: 'shot.png' });
    return screenshot;
  } finally {
    await browser.close();
  }
}

capture('https://example.com').catch((error) => {
  console.error(error);
  process.exitCode = 1;
});

The viewport dimensions are expressed in CSS pixels. Puppeteer documents that page.setViewport() resizes the page and advises setting the viewport before navigation, since sites may not expect their size to change after loading. Puppeteer viewport API

Choose between browser-rendered density and final image size

Use Puppeteer’s scale factor for device-scale rendering

deviceScaleFactor changes the device metrics Puppeteer uses while rendering. Set it on the viewport before loading the page when you want the browser capture to use an emulated device scale factor. The expected relationship between scale and output pixel dimensions follows from the DPR setting, but should not be treated as a guarantee for every full-page, clipped, or differently configured capture.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Sale
Philips 24 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 241V8LB
  • 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

Use Sharp resize for explicit bitmap dimensions

Sharp operates on the captured bitmap. Its resize() method can fit, crop, stretch, or constrain the output image; it does not set Puppeteer’s device scale factor. This example preserves aspect ratio and avoids cropping or stretching while fitting within 1200 by 900 pixels:

const sharp = require('sharp');

const output = await sharp(screenshot)
  .resize({ width: 1200, height: 900, fit: 'inside' })
  .toBuffer();

const metadata = await sharp(output).metadata();
console.log({ width: metadata.width, height: metadata.height });

With fit: 'inside', the output can be smaller than both bounds when the input’s aspect ratio requires it. Select a different fit mode when that is not the intended result:

Rank #2
Philips 22 Inch Computer Monitor FHD 100Hz VA VESA Flicker-Free, 221V8LB
  • 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
  • cover: preserve aspect ratio and crop to cover the target.
  • contain: preserve aspect ratio and fit within the target.
  • fill: stretch to the target dimensions.
  • inside: fit within maximum dimensions.
  • outside: ensure the image meets minimum dimensions, potentially exceeding one bound.

Sharp exposes output dimensions through image metadata. Its density or DPI option is separate from pixel resizing; changing DPI metadata is not a substitute for choosing bitmap dimensions. Sharp resize API Sharp output API

Choose the screenshot area and format separately

The viewport scale factor is independent of the options that define what page.screenshot() captures and how it encodes the result. Puppeteer supports viewport or full-page captures, a clip rectangle, transparency, image formats, and quality for lossy formats. Quality does not apply to PNG. Use element screenshots when a particular element is the target; Puppeteer’s guide notes that it attempts to scroll a hidden element into view before capturing it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.
// Full-page PNG
await page.screenshot({ path: 'full.png', fullPage: true });

// Capture a rectangular region
await page.screenshot({
  path: 'region.png',
  clip: { x: 0, y: 0, width: 640, height: 480 },
});

// JPEG with a lossy-format quality setting
await page.screenshot({ path: 'page.jpg', type: 'jpeg', quality: 85 });

// Capture a specific element
const element = await page.$('main');
if (!element) throw new Error('Target element was not found');
await element.screenshot({ path: 'main.png' });

Check the installed Puppeteer version’s API documentation if you rely on version-specific behavior. The official API pages referenced here identify Puppeteer 25.12.0 as current on October 3, 2026. Puppeteer screenshot API Puppeteer screenshots guide

Check dimensions and troubleshoot unexpected output

When the image dimensions are wrong, inspect the captured file’s pixel metadata first. Then work through the settings in the order they affect the result:

Rank #4
Sale
Samsung 27" Essential S3 (S36GD) Series FHD 1800R Curved Computer Monitor
  • 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
  1. Confirm the width, height, and deviceScaleFactor passed to page.setViewport().
  2. Check whether fullPage or clip changed the captured area.
  3. Check whether Sharp resized, cropped, or otherwise transformed the image after capture.
  4. Compare pixel dimensions, not just DPI or density metadata.
  • Capture looks like the default scale: ensure the factor is set in page.setViewport() before page.goto(), rather than relying on a later resize.
  • Width or height differs from the viewport: determine whether the screenshot is full-page or clipped; those settings change the capture area.
  • Output has an unexpected crop or shape: inspect Sharp’s fit mode. cover crops, fill stretches, and inside may produce dimensions below one or both limits.
  • A hidden element is missing: use the element screenshot API and confirm the selector matches an element; the guide says Puppeteer attempts to scroll a hidden element into view.
  • PNG quality appears unchanged: the screenshot quality setting applies to lossy formats, not PNG.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Use Puppeteer Sharp for .NET

Puppeteer Sharp is a .NET port of the official Node.js Puppeteer API. Its documentation demonstrates setting a viewport before generating a screenshot, but use the option names and syntax for the version installed in your project rather than copying JavaScript directly into C#. Puppeteer Sharp documentation

Or skip the browser setup

ScreenshotNeo provides a screenshot API and MCP server. Its one-call API returns an image or PDF; the response includes page-verdict and billing headers.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
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.
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, popups, and chat widgets are removed before the shot; bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents take screenshots. The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 shots. Sign up for 1,000 free screenshots a month, with no card required.

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
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver 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.