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
codeceptjs-pixelmatchhelper
Pixelmatch helper for CodeceptJS, with support for Playwright, Webdriver, TestCafe, Puppeteer & Appium
dynamicpixelmatch
Exclude some areas from image before comparison using pixelmatch
The smallest, simplest and fastest JavaScript pixel-level image comparison library
npm install pixelmatch
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
6,201 Stars
121 Commits
306 Forks
163 Watching
1 Branches
546 Contributors
Updated on 27 Nov 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-2.2%
502,433
Compared to previous day
Last week
4.5%
2,720,329
Compared to previous week
Last month
6.6%
11,285,635
Compared to previous month
Last year
4%
121,629,713
Compared to previous year
1
2
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
branch protection is not maximal on development and all release branches
Details
Reason
Found 5/30 approved changesets -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
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
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
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