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.

The most direct method is Playwright’s Python Page.screenshot(): open a page, set type="jpeg" (or use a .jpg/.jpeg filename), and choose a JPEG quality from 0 to 100. Add full_page=True for the entire scrollable document; otherwise Playwright captures the current viewport.

Capture a webpage as JPEG with Playwright

Playwright renders the page in a real browser, so the screenshot includes the layout, fonts, images and JavaScript state that exist when the capture occurs. The following synchronous example writes a JPEG directly to disk.

  1. Install the Playwright Python package and its browser binaries using the installation procedure in the official Playwright documentation.
  2. Save this script as webpage_to_jpeg.py.
  3. Run it with Python. The output will be page.jpeg in the current directory.
from playwright.sync_api import sync_playwright

URL = "https://example.com"

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.goto(URL)
    page.screenshot(path="page.jpeg", type="jpeg", quality=85)
    browser.close()

type="jpeg" makes the format explicit. Playwright can also infer the format from page.jpg or page.jpeg; PNG is the documented default when no format is selected. The documented JPEG quality range is 0–100, with a default of 80. Higher values generally preserve more detail while producing larger files, but the documentation does not provide a universal size or speed benchmark.

Choose the area to capture

Viewport screenshot

The example captures the browser’s current viewport. Set the viewport when you need a repeatable canvas rather than the browser’s default:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page(viewport={"width": 1440, "height": 900})
    page.goto("https://example.com")
    page.screenshot(path="viewport.jpeg", type="jpeg", quality=85)
    browser.close()

A viewport shot is useful for a hero section, dashboard view or visual regression check where content below the fold is intentionally excluded.

Full-page screenshot

Pass full_page=True to include the full scrollable document:

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page(viewport={"width": 1440, "height": 900})
    page.goto("https://example.com")
    page.screenshot(
        path="entire-page.jpeg",
        type="jpeg",
        quality=85,
        full_page=True,
    )
    browser.close()

Full-page capture is a page-layout operation, not a promise that every lazy-loaded or continuously changing component will be identical on every run. Wait for the state you need before taking the shot.

One element

Use a locator when the target is a component rather than the page:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.goto("https://example.com")
    page.locator("header").screenshot(
        path="header.jpeg",
        type="jpeg",
        quality=90,
    )
    browser.close()

The locator must resolve to the element you intend to capture. A selector that matches several elements should be narrowed to the required one.

Control JPEG quality, scale and background

Quality

quality accepts an integer from 0 through 100 for JPEG output. The documented default is 80. Choose a lower value when transfer size matters and a higher value when small text or fine detail matters. Quality has no effect on PNG output.

CSS pixels versus device pixels

Playwright can render screenshots at CSS-pixel scale or device-pixel scale. CSS scale keeps one output pixel per CSS pixel. Device scale can create a larger image on a high-DPI display. Select the scale that matches your downstream use: CSS dimensions are usually easier for web comparisons, while device-pixel output can retain more raster detail for printed or high-density displays.

JPEG and transparency

JPEG does not support the transparency behavior exposed by Playwright’s omit_background option. If your result needs a transparent background, choose a format that supports transparency, such as PNG, instead of converting the capture to JPEG.

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

Wait for the page state you actually need

A screenshot records the browser state at capture time. Navigation can finish before an image, chart or client-rendered section is ready. Make the capture deterministic by waiting for a meaningful condition:

from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.goto("https://example.com")
    page.wait_for_selector("main")
    page.screenshot(path="ready.jpeg", type="jpeg", quality=85)
    browser.close()

For a known animation or delayed widget, a deliberate wait can be appropriate, but a selector or other page-state condition is usually more informative than an arbitrary delay. Dynamic advertisements, clocks, carousels and personalized content can still change between runs, so do not treat separate captures as pixel-identical by default.

Save bytes instead of a file

Without a path, screenshot() returns image bytes. This lets you upload, hash or process the JPEG without first creating a temporary file:

from pathlib import Path
from playwright.sync_api import sync_playwright

with sync_playwright() as p:
    browser = p.chromium.launch()
    page = browser.new_page()
    page.goto("https://example.com")
    jpeg_bytes = page.screenshot(type="jpeg", quality=85)
    Path("page.jpeg").write_bytes(jpeg_bytes)
    browser.close()

The bytes are still JPEG data; the format is selected with type="jpeg" just as it is for direct file output.

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

Common failures and fixes

The output is PNG

Check both settings: use type="jpeg" and a filename ending in .jpg or .jpeg. If neither identifies JPEG, Playwright uses its documented PNG default.

The image shows only the visible screen

That is expected for a normal viewport capture. Add full_page=True when the complete scrollable document is required.

The screenshot is blank or missing content

Capture after navigation and after the relevant content appears. Add page.wait_for_selector("your-selector") for a component rendered by JavaScript. Also check that the URL is reachable from the machine running the script and that the selector actually exists.

A locator screenshot fails

The selector may match no element, may match more than one element, or may identify an element that is not visible. Narrow the locator and wait for it before calling screenshot().

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

JPEG transparency is lost

This is a format limitation: Playwright’s omit_background behavior does not apply to JPEG. Capture as PNG when transparent pixels are required.

Runs differ from one another

Browser-rendered pages can vary with time, viewport, device scale, fonts, network responses and live page state. Fix the viewport and relevant settings, wait for stable selectors, and avoid comparing regions that intentionally change. No screenshot API setting can make an inherently dynamic page immutable.

Operational considerations

Performance

Launching a browser for every URL adds startup work. For a batch job, keep one browser process open and create separate pages or contexts as appropriate for your isolation needs. Full-page captures and device-pixel output can produce more data than viewport captures. The Playwright documentation does not establish a universal runtime or file-size advantage for a particular quality, scale or page mode, so measure with your own pages.

Reliability

  • Use an explicit viewport when image dimensions matter.
  • Wait for a page condition that represents readiness.
  • Set a navigation timeout suitable for your network and handle navigation or screenshot exceptions in production code.
  • Record the URL, viewport, format, quality and capture time alongside the file so later comparisons have context.

Security and access

Only capture pages you are authorized to access. If a site requires authentication, configure the browser context with the permitted session or credentials rather than embedding secrets in source code. Respect the site’s terms and privacy requirements when storing screenshots.

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.

Or skip the browser setup

ScreenshotNeo provides a website screenshot API and MCP server. A single GET request returns PNG, JPEG, WebP or PDF, so you do not have to manage a local browser for this workflow. Before capture it accepts the cookie or consent banner like a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets; each cleanup step can be disabled. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and the response identifies the result with X-Page-Verdict and X-Billed headers.

See the ScreenshotNeo API documentation for the complete option set. It supports full-page capture with lazy images loaded, CSS-selector element capture, dark mode, 12 device presets plus custom viewports, retina scale, JPEG quality, PDF paper and page options, custom CSS and JavaScript, pre-capture clicks, hidden selectors, selector/delay/network-idle waits, request and resource blocking, headers, cookies, user agents, Authorization, timezone, geolocation, transparent backgrounds, resizing, chosen-TTL caching, signed links, asynchronous jobs with signed webhooks, 100-URL bulk calls, a usage API and an OpenAPI specification. Common parameter names from other screenshot APIs also work.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

For a JPEG response, request the JPEG output option documented by ScreenshotNeo or use an endpoint configuration that selects JPEG; the example above intentionally follows the supplied API call exactly and saves its response as 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)
r.raise_for_status()
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}`);

Its MCP server exposes take_screenshot, get_page_info and capture_pdf to Claude, Cursor and other MCP clients. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots, with every feature on every plan. Sign up free for 1,000 screenshots a month.

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

Which approach should you choose?

Need Best fit Why
Local automation or test integration Playwright Python You control the browser, page state and returned bytes directly.
A complete scrollable page Either method with full-page capture Playwright uses full_page=True; ScreenshotNeo offers full-page capture with lazy images loaded.
Consent cleanup and no browser maintenance ScreenshotNeo Consent banners, popups and chat widgets are removed before the shot, and failed or blocked loads are not billed.
AI-agent workflow ScreenshotNeo MCP server Use its screenshot, page-info and PDF tools from an MCP client.

Frequently asked questions

Can I use .jpg instead of .jpeg?

Yes. Playwright infers the image format from either JPEG extension, although explicitly setting type="jpeg" makes the intent clear.

Does JPEG preserve transparency?

No. Use a transparency-capable format such as PNG when transparent pixels are part of the result.

What quality should I use?

Start with the documented default of 80, then adjust for your visual and storage requirements. There is no single quality value that is optimal for every webpage.

Can I capture only one component?

Yes. Call screenshot() on a locator for the element you want rather than on the page.

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

Frequently Asked Questions

Can I use .jpg instead of .jpeg?

Yes. Playwright recognizes both extensions for JPEG output.

Does JPEG preserve transparency?

No. Choose PNG when transparent pixels are required.

What quality should I use?

The documented default is 80; select another value from 0 to 100 based on your own visual and storage needs.

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.

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