skillfed

pixelmatch

A pixel-level image comparison library.

pixelmatch v0.4.0 827.4K downloads/30d#4,957 on PyPI141
Permissive license ISC Active released

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 pixelmatch

uv

uv add pixelmatch

poetry

poetry add pixelmatch

Installing 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

License :: OSI ApprovedProgramming Language :: Python :: 3Programming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14

Tags

pixel-level image comparisonscreenshot diff detectionvisual regression testingimage similarity matchinganti-aliased pixel detectionperceptual color differenceimage diff output
image-comparisonvisual-testingregression-detection

More Testing packages