All Projects → mapbox → Pixelmatch

mapbox / Pixelmatch

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

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Pixelmatch

dify
A fast pixel-by-pixel image comparison tool in Rust
Stars: ✭ 41 (-99.08%)
Mutual labels:  diff, image-comparison
Winmerge
WinMerge is an Open Source differencing and merging tool for Windows. WinMerge can compare both folders and files, presenting differences in a visual text format that is easy to understand and handle.
Stars: ✭ 2,358 (-46.98%)
Mutual labels:  diff, image-comparison
Django Dynamic Fixture
A complete library to create dynamic model instances for testing purposes.
Stars: ✭ 341 (-92.33%)
Mutual labels:  testing-tools
Testfx
MSTest V2 framework and adapter
Stars: ✭ 391 (-91.21%)
Mutual labels:  testing-tools
Gofight
Testing API Handler written in Golang.
Stars: ✭ 365 (-91.79%)
Mutual labels:  testing-tools
Mockttp
Powerful friendly HTTP mock server & proxy
Stars: ✭ 346 (-92.22%)
Mutual labels:  testing-tools
Gojsondiff
Go JSON Diff
Stars: ✭ 371 (-91.66%)
Mutual labels:  diff
Differ
A simple gem for generating string diffs
Stars: ✭ 336 (-92.44%)
Mutual labels:  diff
Tcpcopy
An online request replication tool, also a tcp stream replay tool, fit for real testing, performance testing, stability testing, stress testing, load testing, smoke testing, etc
Stars: ✭ 4,028 (-9.42%)
Mutual labels:  testing-tools
Isolator
Detect non-atomic interactions within DB transactions
Stars: ✭ 362 (-91.86%)
Mutual labels:  testing-tools
Similar
A high level diffing library for rust based on diffs
Stars: ✭ 386 (-91.32%)
Mutual labels:  diff
Zora
Lightest, yet Fastest Javascript test runner for nodejs and browsers
Stars: ✭ 356 (-91.99%)
Mutual labels:  testing-tools
Serenity Js
A next generation, full-stack acceptance testing framework optimised for collaboration, speed and scale!
Stars: ✭ 346 (-92.22%)
Mutual labels:  testing-tools
Bento
Swift library for building component-based interfaces on top of UITableView and UICollectionView 🍱
Stars: ✭ 371 (-91.66%)
Mutual labels:  diff
Gsync
gSync is an rsync based library for sending delta updates of files to a remote server.
Stars: ✭ 344 (-92.26%)
Mutual labels:  diff
Miragejs
A client-side server to build, test and share your JavaScript app
Stars: ✭ 4,384 (-1.42%)
Mutual labels:  testing-tools
Diffr
Yet another diff highlighting tool
Stars: ✭ 338 (-92.4%)
Mutual labels:  diff
Trustme
#1 quality TLS certs while you wait, for the discerning tester
Stars: ✭ 355 (-92.02%)
Mutual labels:  testing-tools
Jsondiffpatch
Diff & patch JavaScript objects
Stars: ✭ 3,951 (-11.15%)
Mutual labels:  diff
Excelmerge
GUI Diff Tool for Excel
Stars: ✭ 425 (-90.44%)
Mutual labels:  diff

pixelmatch

Build Status

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).

const numDiffPixels = pixelmatch(img1, img2, diff, 800, 600, {threshold: 0.1});

Implements ideas from the following papers:

Demo

Example output

expected actual diff
1diff
1diff
1diff

API

pixelmatch(img1, img2, output, width, height[, options])

  • 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.

Command line

Pixelmatch comes with a binary that works with PNG images:

pixelmatch image1.png image2.png output.png 0.1

Example usage

Node.js

const fs = require('fs');
const PNG = require('pngjs').PNG;
const pixelmatch = require('pixelmatch');

const img1 = PNG.sync.read(fs.readFileSync('img1.png'));
const img2 = PNG.sync.read(fs.readFileSync('img2.png'));
const {width, height} = img1;
const diff = new PNG({width, height});

pixelmatch(img1.data, img2.data, diff.data, width, height, {threshold: 0.1});

fs.writeFileSync('diff.png', PNG.sync.write(diff));

Browsers

const img1 = img1Context.getImageData(0, 0, width, height);
const img2 = img2Context.getImageData(0, 0, width, height);
const diff = diffContext.createImageData(width, height);

pixelmatch(img1.data, img2.data, diff.data, width, height, {threshold: 0.1});

diffContext.putImageData(diff, 0, 0);

Install

Install with NPM:

npm install pixelmatch

Use in the browser from a CDN:

<script src="https://bundle.run/pixelmatch"></script>

Changelog

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].