mapbox/pixelmatch

The smallest, simplest and fastest JavaScript pixel-level image comparison library

View on GitHub ↗Jump to charts ↓

Summary Information

Updated 50 minutes ago
Added to GitGenius on July 8th, 2022
Created on October 13th, 2015
Open Issues & Pull Requests: 15 (+0)
Number of forks: 323
Total Stargazers: 6,926 (+0)
Total Subscribers: 160 (+0)

Repository Insights (GitGenius)

Median issue/PR response: 98.1 days
Mean response time: 442.1 days
90th percentile: 945.3 days
Tracked items: 20

Charts & Analytics

Fetching additional details & charts...

Issue Activity (beta)

Open issues: 8
New in 7 days: 0
Closed in 7 days: 0
Avg open age: 1,474 days
Stale 30+ days: 8
Stale 90+ days: 7

Recent activity

Opened in 7 days: 0
Closed in 7 days: 0
Comments in 7 days: 0
Events in 7 days: 0

Top labels

  • enhancement (11)
  • question (8)
  • bug (3)
  • tests (1)

Most active issues this week

No issue events were indexed in the last 7 days.

Detailed Description

Pixelmatch is a JavaScript library designed for pixel-level image comparison, created by Mapbox to enable screenshot testing and visual regression detection. The library implements accurate anti-aliased pixel detection and perceptual color difference metrics, making it suitable for automated visual testing workflows. At approximately 150 lines of code with zero dependencies, pixelmatch operates directly on raw typed arrays of image data, enabling blazing-fast performance across any JavaScript environment including Node.js and browsers.

The core API accepts two image buffers to compare along with output dimensions and optional configuration parameters. The library returns the count of mismatched pixels and can generate a visual diff image showing where differences occur. Configuration options include a threshold parameter ranging from 0 to 1 that controls comparison sensitivity, an includeAA flag to disable anti-aliased pixel detection, and customizable color output for visualizing differences. Users can specify separate colors for anti-aliased pixels and differing pixels, apply blending factors to unchanged pixels in the output, and optionally render diffs as transparent masks rather than overlays on the original image.

The implementation draws from academic research on perceptual color spaces and anti-aliasing detection. Specifically, pixelmatch incorporates ideas from a 2010 paper on measuring perceived color difference using YIQ NTSC transmission color space and a 2009 paper on anti-aliased pixel and intensity slope detection. This theoretical foundation allows the library to distinguish between actual image differences and artifacts introduced by anti-aliasing, reducing false positives in visual regression testing.

Pixelmatch was inspired by existing solutions like Resemble.js and Blink-diff but differentiates itself through its minimal footprint and lack of external dependencies. The library works with Buffer objects, Uint8Array, and Uint8ClampedArray formats, providing flexibility for different data sources. Beyond the programmatic API, pixelmatch includes a command-line binary for comparing PNG images directly, extending its utility beyond JavaScript environments.

The repository maintains connections with major projects including Microsoft's VSCode and TypeScript implementations as well as the Rust language repository through overlapping contributor networks, suggesting adoption and influence within significant open-source ecosystems.