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.

Use Playwright for Python to capture both page states under the same browser and viewport conditions, then compare the resulting images with a Python pixel-diff tool such as pixelmatch. Save a difference image as well as a numeric result: the image helps you judge what changed, while the number lets your test apply an explicit tolerance. Pixel differences are sensitive to rendering variation, so control the environment and review proposed baseline updates.

How the comparison works

A visual comparison has two separate jobs: capturing equivalent renders and deciding which pixel changes matter. Playwright’s Python API handles capture; an image-diff stage compares the captures. The Python package pixelmatch on PyPI describes pixel-level comparison, PIL.Image support, anti-aliased-pixel detection, and perceptual colour-difference metrics. Check its current compatibility and maintenance before adopting it for a long-lived project; those details are not established here.

Playwright’s toHaveScreenshot() assertion is documented for Playwright Test and uses pixelmatch. It is not an automatic Python assertion: in Python, capture with Playwright and call an image-comparison implementation separately. See the Playwright visual comparisons guide and Playwright for Python screenshot documentation.

Install the Python tools

Install Playwright for Python and its browser binaries, plus Pillow and pixelmatch. The code below uses Playwright’s async Python API and the pixelmatch Python package interface that accepts PIL images.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
  1. Create and activate a virtual environment for the project.

  2. Install the packages: python -m pip install playwright pillow pixelmatch.

  3. Install a Playwright browser: python -m playwright install chromium.

Package APIs can change. If the pixelmatch import or call signature differs in the version you install, consult the package’s current PyPI documentation rather than assuming the JavaScript package interface applies unchanged.

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

Capture and compare two page states

This example captures a reference and a current version at the same viewport, waits for the page to reach a usable state, loads each PNG with Pillow, and writes a visual diff. It assumes the page content is stable between captures; for changing sites, control test data or use a fixed test state before relying on the result.

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
import asyncio
from pathlib import Path

from PIL import Image
from pixelmatch import pixelmatch
from playwright.async_api import async_playwright

URL = "https://example.com"
REFERENCE_PATH = Path("reference.png")
CURRENT_PATH = Path("current.png")
DIFF_PATH = Path("diff.png")

async def capture(url: str, output_path: Path) -> None:
    async with async_playwright() as p:
        browser = await p.chromium.launch()
        page = await browser.new_page(
            viewport={"width": 1280, "height": 800},
            device_scale_factor=1,
        )
        await page.goto(url, wait_until="networkidle")
        await page.screenshot(path=str(output_path), full_page=True)
        await browser.close()

async def main() -> None:
    await capture(URL, REFERENCE_PATH)
    await capture(URL, CURRENT_PATH)

    reference = Image.open(REFERENCE_PATH).convert("RGBA")
    current = Image.open(CURRENT_PATH).convert("RGBA")

    if reference.size != current.size:
        raise ValueError(
            f"Image sizes differ: {reference.size} vs {current.size}. "
            "Capture both pages with the same viewport and page state."
        )

    diff = Image.new("RGBA", reference.size)
    changed_pixels = pixelmatch(
        reference,
        current,
        diff,
        includeAA=False,
    )
    diff.save(DIFF_PATH)
    total_pixels = reference.width * reference.height
    print(f"Changed pixels: {changed_pixels} / {total_pixels}")
    print(f"Diff image: {DIFF_PATH}")

    # Example policy only: choose a threshold appropriate for your application.
    allowed_changed_pixels = 100
    if changed_pixels > allowed_changed_pixels:
        raise AssertionError(
            f"Visual difference exceeds policy: {changed_pixels} > "
            f"{allowed_changed_pixels}; inspect {DIFF_PATH}"
        )

asyncio.run(main())

The example treats the first capture as the reference, but a repeatable test should normally capture a known-good baseline once, store it under version control or an intentional artifact-retention policy, and compare new runs against it. Do not overwrite that baseline automatically when a test fails: inspect the difference, confirm whether the change is intended, then update the accepted reference deliberately.

Capture a viewport, full page, or one element

Playwright can write a screenshot to a file, return screenshot bytes for further processing, capture the full page, or target an element. Keep the selected scope identical on both sides of a comparison.

# Viewport screenshot saved to a file
await page.screenshot(path="viewport.png")

# Entire scrollable page
await page.screenshot(path="full-page.png", full_page=True)

# Screenshot as bytes, useful when passing data to another image pipeline
png_bytes = await page.screenshot()

# A particular element
await page.locator("main article").screenshot(path="article.png")

When you capture an element, make sure the locator identifies the same intended element in both runs. Full-page screenshots can expose lazy-loaded content or page sections that are not present in a viewport capture; wait for the relevant content to load before taking either screenshot.

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

Choose a meaningful difference policy

Exact equality is appropriate only when the rendering environment and page state are deterministic enough that identical output is expected. Otherwise, define and justify tolerance rather than treating every changed pixel as a defect or ignoring all small changes.

  • Changed-pixel allowance: Set a maximum count that fits the captured region and the kinds of harmless variation your application permits. A count that works for a small element capture may be too strict or too lax for a full-page image.

    Rank #3
    Sale
    Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
    • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
    • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
    • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
    • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
    • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
  • Per-pixel colour tolerance: A perceptual comparison can treat small colour differences differently from large ones. The threshold is a policy choice; a more permissive setting can conceal a genuine visual regression.

  • Anti-aliasing: Text and edges can differ slightly across render environments. Pixelmatch advertises anti-aliased-pixel handling, but decide whether excluding those pixels is suitable for your UI and review the resulting diff.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  • Diff image review: A count cannot tell you whether a change is a broken layout, an intentional content update, or harmless rendering noise. Inspect the highlighted image when a comparison fails.

Playwright’s visual-comparison documentation describes threshold as a perceived colour-difference tolerance and maxDiffPixels as an allowed count of differing pixels. It gives an example maxDiffPixels: 100 and documents a threshold scale from 0 (strict) to 1 (lax), with a JavaScript documentation default of 0.2. Those are Playwright Test settings, not recommended defaults for a separate Python pixel-diff implementation.

Make captures reproducible

Screenshot output can vary with the host operating system, browser version, browser settings, hardware, power source, and headless mode. Run reference and current captures in a consistent environment, and keep capture settings the same.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

The Playwright visual-comparison guide notes that rendering varies across environments and documents a stylePath option for hiding volatile regions in its test workflow. If using Python with a separate diff step, apply equivalent control in your own capture or test setup; do not assume that Playwright Test options are available directly in Python.

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

Common problems and fixes

The images have different dimensions

The captures used different viewport settings, device scale factors, page lengths, or target elements. Match those settings and make sure both pages reach equivalent content before capture. If the page content legitimately differs in length, decide whether full-page comparison is the right scope or whether a stable element is more meaningful.

The test reports changes on an unchanged page

Check for changing content and environment drift first: clocks, asynchronous updates, animation, randomized data, browser version, operating system, or headless configuration. Stabilize page state and capture conditions before increasing tolerance; a broader tolerance can hide actual regressions.

The diff is noisy around text or edges

Small rasterization differences can affect anti-aliased edges. Confirm that both captures use the same environment, then evaluate the diff implementation’s anti-alias handling and perceptual threshold. Review the changed image before accepting an exception.

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

The screenshot is blank or incomplete

Verify navigation completed and that the page reached the state your test expects. Wait for a meaningful selector or application-ready condition when possible; a generic network-idle condition may not represent readiness for every site. For lazy-loaded content, ensure the relevant region has been brought into view or otherwise loaded before capturing.

The baseline update makes the failure disappear

An updated reference can hide a real defect if it is accepted without review. Keep baseline updates deliberate: inspect the diff, confirm the intended UI change, and only then replace the known-good image. Playwright Test documents a separate snapshot-update operation in its baseline workflow; a Python project should likewise make baseline changes explicit.

Or skip the browser setup

ScreenshotNeo provides a screenshot API and MCP server for developers. A single request can capture a URL as an image or PDF; compare the returned image with your Python diff stage if you want to keep pixel analysis in your own code. Its capture process accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before the shot; each step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies page verdict and billing status in headers. An MCP server exposes screenshot tools for AI agents, including Claude and Cursor. The free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots.

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 and response details. For Python, the same one-request capture can be made with:

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.
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)

Sign up for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

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.