October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
browser zoom

How to Capture a Chrome Extension Element Screenshot at Any Zoom Level

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

To capture one DOM element reliably from a Chrome extension, measure the element in CSS pixels, capture the visible tab, derive the bitmap scale from the returned image dimensions, and crop with that measured scale. Do not multiply coordinates by the browser zoom percentage: Chrome zoom and window.devicePixelRatio describe different things, and the screenshot bitmap is the final authority.

What the workflow actually captures

chrome.tabs.captureVisibleTab() captures the visible area of the active tab, not an arbitrary DOM node. Your extension therefore performs two separate jobs:

  1. A content script finds the element and reports its rectangle in CSS pixels.
  2. The extension captures the viewport, maps that rectangle into bitmap pixels, and crops the image.

This boundary explains most offset bugs. getBoundingClientRect() returns coordinates relative to the layout viewport; the PNG returned by Chrome has physical bitmap dimensions. Browser zoom, display scaling, and device pixel ratio can make those coordinate systems differ.

Permissions and extension structure

A user-invoked capture can use the activeTab permission. An extension that must work on matching sites without a user gesture needs suitable host permissions, commonly all_urls. The content script also needs access to the page where the element lives. Browser-internal pages, restricted extension pages, and some cross-origin frames cannot be read as ordinary page DOM.

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
{
  "manifest_version": 3,
  "name": "Element capture example",
  "version": "1.0.0",
  "permissions": ["activeTab", "tabs", "scripting"],
  "action": { "default_title": "Capture element" },
  "background": { "service_worker": "service-worker.js" }
}

Keep the capture operation in the extension context. Run DOM inspection in a content script or through chrome.scripting.executeScript; call captureVisibleTab from the service worker or another extension page.

Collect geometry in the page

First locate the element, scroll it into view, allow layout to settle, and then measure it. Re-measuring after scrolling matters because sticky headers, lazy content, font loading, and scroll-linked effects can change the rectangle.

async function measureElement(selector) {
  const element = document.querySelector(selector);
  if (!element) throw new Error(`No element matches ${selector}`);

  element.scrollIntoView({ block: 'center', inline: 'nearest' });
  await new Promise(requestAnimationFrame);
  await new Promise(requestAnimationFrame);

  const rect = element.getBoundingClientRect();
  return {
    left: rect.left,
    top: rect.top,
    width: rect.width,
    height: rect.height,
    scrollX: window.scrollX,
    scrollY: window.scrollY,
    innerWidth: window.innerWidth,
    innerHeight: window.innerHeight,
    devicePixelRatio: window.devicePixelRatio
  };
}

For a picker, replace the selector with the element selected by a pointer handler. Return the selector or a stable identifier along with the geometry so the service worker can request a fresh measurement immediately before capture.

Capture the visible tab and crop it

The following service-worker example injects the measurement function, captures the tab, loads the data URL into an image, and crops to the element. It derives independent horizontal and vertical scales from the image itself.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
async function captureElement(tabId, selector) {
  const [{ result: box }] = await chrome.scripting.executeScript({
    target: { tabId },
    func: measureElement,
    args: [selector]
  });

  if (!box || box.width <= 0 || box.height <= 0) {
    throw new Error('The element has no visible size');
  }

  const dataUrl = await chrome.tabs.captureVisibleTab(
    tabId,
    { format: 'png' }
  );
  const image = await loadImage(dataUrl);
  const scaleX = image.naturalWidth / box.innerWidth;
  const scaleY = image.naturalHeight / box.innerHeight;

  const left = clamp(Math.round(box.left * scaleX), 0, image.naturalWidth);
  const top = clamp(Math.round(box.top * scaleY), 0, image.naturalHeight);
  const right = clamp(Math.round((box.left + box.width) * scaleX), left, image.naturalWidth);
  const bottom = clamp(Math.round((box.top + box.height) * scaleY), top, image.naturalHeight);

  const canvas = new OffscreenCanvas(right - left, bottom - top);
  const context = canvas.getContext('2d');
  context.drawImage(image, left, top, right - left, bottom - top,
                    0, 0, right - left, bottom - top);
  const blob = await canvas.convertToBlob({ type: 'image/png' });
  return blob;
}

function clamp(value, min, max) {
  return Math.min(Math.max(value, min), max);
}

function loadImage(dataUrl) {
  return new Promise((resolve, reject) => {
    const image = new Image();
    image.onload = () => resolve(image);
    image.onerror = reject;
    image.src = dataUrl;
  });
}

In a window or document context that lacks OffscreenCanvas, use a normal canvas element and export it with toBlob. The coordinate calculation remains the same.

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

Why zoom causes offsets

Browser zoom is not DPR

chrome.tabs.getZoom() reports the tab’s browser zoom factor. The page’s window.devicePixelRatio reports the relationship between physical display pixels and CSS pixels. They can change independently. At 125%, 150%, or 200% zoom, assuming one bitmap pixel per CSS pixel will usually misplace the crop.

Measure the returned bitmap

For a normal viewport capture, use image.width / innerWidth and image.height / innerHeight. Those ratios include the effective rendering scale used for that capture. Use separate scaleX and scaleY; do not assume they are identical.

Handle a zoom change during capture

If the user changes zoom while your picker is running, the old rectangle may no longer match the new bitmap. Listen for Chrome’s zoom-change event where appropriate, or simply measure again directly before calling captureVisibleTab. Treat a zoom change as invalidating the pending geometry.

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.

Elements larger than the viewport

captureVisibleTab cannot produce a single image taller than the visible viewport. Capture a tall element in slices:

Rank #3
Sale
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.
  1. Record its document-space top (rect.top + scrollY) and measured height.
  2. Choose viewport scroll positions that cover the element from top to bottom.
  3. Scroll to each position and wait for two animation frames, plus any required image or font readiness.
  4. Measure the element again, capture the viewport, and crop only the visible intersection with the element.
  5. Place each slice at its document-space offset in a canvas, then export the stitched result.

Fixed and sticky headers can appear in every slice. Hide them temporarily, compensate for their repeated pixels, or stitch only the element’s intersection after each scroll. Lazy-loaded images may change the element’s height; wait for them to load and verify the final stitched height against a fresh measurement.

A robust stitching outline

const first = await measureElement(selector);
const documentTop = first.top + first.scrollY;
const targetHeight = first.height;
const slices = [];

for (let y = documentTop; y < documentTop + targetHeight; y += first.innerHeight) {
  await chrome.scripting.executeScript({
    target: { tabId },
    func: y => window.scrollTo({ top: y, behavior: 'instant' }),
    args: [y]
  });
  await new Promise(resolve => setTimeout(resolve, 100));
  const current = await /* re-run measureElement */;
  const viewport = await chrome.tabs.captureVisibleTab(tabId, { format: 'png' });
  // Map the element/viewport intersection to bitmap pixels and save a slice.
  slices.push({ current, viewport });
}
// Draw slices in document order and compare the canvas height with targetHeight.

The comment marks the image-decoding and placement code, which is the same scale-and-clamp operation used for a single viewport capture.

Timing, rate limits, and reliability

  • Wait for fonts, images, and layout before measuring. A screenshot taken while a web font swaps can have different line breaks from the rectangle you measured.
  • Do not capture in a tight loop. Chrome documents a maximum of two captureVisibleTab calls per second and describes the operation as expensive. Queue slice requests and space them out.
  • Use a fresh rectangle for every slice. Scrolling can trigger lazy loading, sticky-position changes, and resize observers.
  • Clamp every crop edge to the bitmap. Fractional CSS coordinates and rounding can otherwise request pixels outside the image.
  • Expect animation to create nondeterministic output. Pause animation with injected CSS when reproducibility matters, then remove that CSS after capture.

Common failures and fixes

“The crop is shifted at 150% zoom”

Cause: multiplying CSS coordinates by the zoom percentage or DPR. Fix: decode the returned image and compute scale from bitmap dimensions divided by the reported viewport dimensions.

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

“Only the top portion was captured”

Cause: the API captures the visible tab only. Fix: scroll, capture, crop each visible intersection, and stitch slices; account for sticky headers.

“No element matches”

Cause: the selector ran in the wrong frame, before the app rendered, or against a shadow DOM boundary. Fix: wait for the application state, target the correct frame, or add page-side code that can query the relevant shadow root.

“Cannot access this page”

Cause: missing host permission, a browser-internal URL, or a page that blocks extension access. Fix: request the narrow permission needed, trigger the flow with activeTab, or move the capture boundary to a page you can access. Some restricted pages cannot be captured through this DOM workflow.

Rank #4
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

“The image is blank or stale”

Cause: capture occurred before navigation, fonts, or lazy images settled. Fix: wait for a known selector, network idle where your page permits it, and image completion; then re-measure.

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

“The extension hits a rate error”

Cause: more than two visible-tab captures per second. Fix: add a queue with at least a 500 ms interval and retry only transient failures.

“A cross-origin iframe element is missing”

Cause: the parent content script cannot inspect another origin’s DOM. Fix: install a permitted content script in that frame when possible, or capture the frame as a separate boundary and compose the result.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Validate with DevTools

For a one-off check, Chrome DevTools can capture the current viewport or a full-size page from its screenshot menu. DevTools’ Protocol Monitor can issue Chrome DevTools Protocol commands such as Page.captureScreenshot. Comparing a DevTools image with your extension output helps confirm whether an error is in page geometry, bitmap scaling, or stitching. A repeatable extension still needs its own picker, permission handling, and queue.

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.

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server when you need a URL image rather than an in-browser DOM picker. Its element capture accepts a CSS selector, and its options include full-page capture with lazy images loaded, device presets or custom viewports, retina scale, custom JavaScript and CSS, click actions, waits, request blocking, headers, cookies, user agents, timezone and geolocation.

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

One request returns an image or PDF. See the ScreenshotNeo documentation for parameters and response headers.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);

ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be disabled. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and each response identifies the page verdict and billing status with X-Page-Verdict and X-Billed headers. Its MCP server exposes take_screenshot, get_page_info, and capture_pdf for Claude, Cursor, and other MCP clients.

The Free plan includes 1,000 shots per month without a card. Paid plans start at $5 for 3,000 shots; yearly billing gives two months free, and every feature is included on every plan. Sign up for the free plan.

Practical checklist

  • Use activeTab or the required host permission.
  • Measure after scrolling and after layout settles.
  • Record viewport dimensions and DPR for diagnostics.
  • Capture, decode, and derive scale from the actual bitmap.
  • Clamp crop coordinates and preserve fractional geometry until final rounding.
  • Re-measure after any zoom, resize, navigation, or lazy-load event.
  • Queue captures at no more than two per second.
  • Stitch viewport slices for elements taller than the viewport.

Frequently Asked Questions

Can I capture an element without taking a full viewport screenshot?

Not with captureVisibleTab; that API returns the visible tab. You must crop its bitmap, or use a URL screenshot service with selector support when the page is publicly reachable.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

Should I use chrome.tabs.getZoom() in the crop formula?

Use it for diagnostics and zoom-change handling, not as the bitmap multiplier. Compute scale from the captured image dimensions and innerWidth/innerHeight.

Why does a stitched image have a different height than the DOM element?

Lazy content, font swaps, sticky overlays, or rounding may have changed geometry between slices. Re-measure after the final slice and compare document-space offsets with the canvas height.

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.

Read next

Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.