pixelmatch
A pixel-level image comparison library.
What it is and what it does
pixelmatch is a Python port of the Mapbox pixelmatch library, designed to detect pixel-level differences between two images. It implements anti-aliased pixel detection and perceptual color difference metrics based on published research papers, making it suitable for visual regression testing and screenshot comparison in automated tests.
The library accepts images as raw RGBA pixel data and outputs the count of differing pixels while optionally generating a visual diff image. Key parameters control sensitivity via threshold (ranging from 0 to 1), anti-aliasing handling, and diff visualization options like pixel blending and masking. A contrib module provides additional integration patterns for image instances.
Use it for:
- Automated visual regression testing in UI test suites to detect unintended rendering changes
- Screenshot comparison in end-to-end tests to verify application state visually
- Batch image quality validation to flag images that deviate from expected reference images
- Diff generation for visual debugging, highlighting exactly which pixels differ between two versions
- Integration with CI/CD pipelines to fail builds when visual changes exceed acceptable thresholds
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Compares two images pixel-by-pixel to detect differences, with support for anti-aliased pixel detection and perceptual color metrics, returning a count of mismatched pixels and optionally generating a visual diff.
Yes. Low install friction, no external dependencies, active maintenance, permissive ISC license, and no known vulnerabilities make it a safe choice. Well-suited for visual testing workflows; install if you need pixel-level image comparison or screenshot diffing in tests.
Install
pixelmatch on PyPI
pip
pip install pixelmatchuv
uv add pixelmatchpoetry
poetry add pixelmatchInstalling pixelmatch
Before you install
Low friction: pure Python wheel with no runtime dependencies. Actively maintained as of 2026-03-07, with recent performance improvements in v0.4.0. Supports current Python versions (3.10–3.14).
License in practice
ISC license is permissive, allowing use in commercial and proprietary projects with minimal restrictions.
Quickstart
from pixelmatch import pixelmatch
num_diff_pixels = pixelmatch(img1, img2, 800, 600, diff, threshold=0.1)
Requires Python 3.10 or later. Images must have equal dimensions and be in RGBA format.
Verify before relying
- Whether the contrib.PIL module requires an external image library as an optional dependency
- Performance characteristics on very large images or batch comparisons
Package facts
| License | ISC (permissive) |
| Python support | supports the current Python release (<4.0,>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 160 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 827,412/month — #4,957 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pixelmatch-0.4.0-py3-none-any.whl
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
pixelhogCompares PNG screenshots pixel-by-pixel and…
permissive · top 5,000 on PyPI
pytest-playwright-visualA pytest plugin that captures and compares…
permissive · top 15,000 on PyPI
gradio-imagesliderA Gradio component that displays two images…
permissive · top 15,000 on PyPI
recursive-diffRecursively compares two Python data structures…
permissive · top 15,000 on PyPI
pyjsonCompares the similarity between two JSON files…
permissive · top 15,000 on PyPI
PyScreezePyScreeze captures screenshots and locates…
permissive · top 5,000 on PyPI
jsoncomparisonCompares two JSON-like objects and returns a…
permissive · top 5,000 on PyPI
rich-pixelsRenders pixel images and ASCII art grids to the…
unclear · top 15,000 on PyPI
lpipsComputes perceptual similarity between image…
permissive · top 5,000 on PyPI
ImageHashImageHash computes perceptual fingerprints of…
permissive · top 5,000 on PyPI