Gathering detailed insights and metrics for pixelmatch
Gathering detailed insights and metrics for pixelmatch
Gathering detailed insights and metrics for pixelmatch
Gathering detailed insights and metrics for pixelmatch
@types/pixelmatch
TypeScript definitions for pixelmatch
@loki/diff-pixelmatch
Loki pixelmatch image differ
@bokuweb/pixelmatch-wasm
A pixel-level image comparison library powered by wasm and SIMD feature, originally created to compare screenshots in tests.
odiff-bin
The fastest image difference tool in the world
The smallest, simplest and fastest JavaScript pixel-level image comparison library
npm install pixelmatch
Typescript
Module System
Node Version
NPM Version
JavaScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
ISC License
6,483 Stars
136 Commits
319 Forks
168 Watchers
1 Branches
627 Contributors
Updated on Jul 14, 2025
Latest Version
7.1.0
Package Id
pixelmatch@7.1.0
Unpacked Size
18.97 kB
Size
6.20 kB
File Count
6
NPM Version
11.1.0
Node Version
22.13.1
Published on
Feb 21, 2025
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
1
3
The smallest, simplest and fastest JavaScript pixel-level image comparison library, originally created to compare screenshots in tests.
Features accurate anti-aliased pixels detection and perceptual color difference metrics.
Inspired by Resemble.js and Blink-diff. Unlike these libraries, pixelmatch is around 150 lines of code, has no dependencies, and works on raw typed arrays of image data, so it's blazing fast and can be used in any environment (Node or browsers).
1const numDiffPixels = pixelmatch(img1, img2, diff, 800, 600, {threshold: 0.1});
Implements ideas from the following papers:
expected | actual | diff |
---|---|---|
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
![]() | ![]() | ![]() |
img1
, img2
— Image data of the images to compare (Buffer
, Uint8Array
or Uint8ClampedArray
). Note: image dimensions must be equal.output
— Image data to write the diff to, or null
if don't need a diff image.width
, height
— Width and height of the images. Note that all three images need to have the same dimensions.options
is an object literal with the following properties:
threshold
— Matching threshold, ranges from 0
to 1
. Smaller values make the comparison more sensitive. 0.1
by default.includeAA
— If true
, disables detecting and ignoring anti-aliased pixels. false
by default.alpha
— Blending factor of unchanged pixels in the diff output. Ranges from 0
for pure white to 1
for original brightness. 0.1
by default.aaColor
— The color of anti-aliased pixels in the diff output in [R, G, B]
format. [255, 255, 0]
by default.diffColor
— The color of differing pixels in the diff output in [R, G, B]
format. [255, 0, 0]
by default.diffColorAlt
— An alternative color to use for dark on light differences to differentiate between "added" and "removed" parts. If not provided, all differing pixels use the color specified by diffColor
. null
by default.diffMask
— Draw the diff over a transparent background (a mask), rather than over the original image. Will not draw anti-aliased pixels (if detected).Compares two images, writes the output diff and returns the number of mismatched pixels.
Pixelmatch comes with a binary that works with PNG images:
1pixelmatch image1.png image2.png output.png 0.1
1import fs from 'fs'; 2import {PNG} from 'pngjs'; 3import pixelmatch from 'pixelmatch'; 4 5const img1 = PNG.sync.read(fs.readFileSync('img1.png')); 6const img2 = PNG.sync.read(fs.readFileSync('img2.png')); 7const {width, height} = img1; 8const diff = new PNG({width, height}); 9 10pixelmatch(img1.data, img2.data, diff.data, width, height, {threshold: 0.1}); 11 12fs.writeFileSync('diff.png', PNG.sync.write(diff));
1const img1 = img1Context.getImageData(0, 0, width, height); 2const img2 = img2Context.getImageData(0, 0, width, height); 3const diff = diffContext.createImageData(width, height); 4 5pixelmatch(img1.data, img2.data, diff.data, width, height, {threshold: 0.1}); 6 7diffContext.putImageData(diff, 0, 0);
Install with NPM:
1npm install pixelmatch
Or use in the browser from a CDN:
1<script type="module"> 2 import pixelmatch from 'https://esm.run/pixelmatch';
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
security policy file detected
Details
Reason
1 existing vulnerabilities detected
Details
Reason
SAST tool is not run on all commits -- score normalized to 6
Details
Reason
branch protection is not maximal on development and all release branches
Details
Reason
Found 12/25 approved changesets -- score normalized to 4
Reason
2 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 3
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Score
Last Scanned on 2025-07-07
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More