pixelmatch
Advanced tools
Comparing version 5.0.2 to 5.1.0
10
index.js
@@ -10,3 +10,4 @@ 'use strict'; | ||
aaColor: [255, 255, 0], // color of anti-aliased pixels in diff output | ||
diffColor: [255, 0, 0] // color of different pixels in diff output | ||
diffColor: [255, 0, 0], // color of different pixels in diff output | ||
diffMask: false // draw the diff over a transparent background (a mask) | ||
}; | ||
@@ -36,3 +37,3 @@ | ||
if (identical) { // fast path if identical | ||
if (output) { | ||
if (output && !options.diffMask) { | ||
for (let i = 0; i < len; i++) drawGrayPixel(img1, 4 * i, options.alpha, output); | ||
@@ -66,3 +67,4 @@ } | ||
// one of the pixels is anti-aliasing; draw as yellow and do not count as difference | ||
if (output) drawPixel(output, pos, aaR, aaG, aaB); | ||
// note that we do not include such pixels in a mask | ||
if (output && !options.diffMask) drawPixel(output, pos, aaR, aaG, aaB); | ||
@@ -77,3 +79,3 @@ } else { | ||
// pixels are similar; draw background as grayscale image blended with white | ||
drawGrayPixel(img1, pos, options.alpha, output); | ||
if (!options.diffMask) drawGrayPixel(img1, pos, options.alpha, output); | ||
} | ||
@@ -80,0 +82,0 @@ } |
{ | ||
"name": "pixelmatch", | ||
"version": "5.0.2", | ||
"version": "5.1.0", | ||
"description": "The smallest and fastest pixel-level image comparison library.", | ||
@@ -16,5 +16,5 @@ "main": "index.js", | ||
"devDependencies": { | ||
"eslint": "^5.16.0", | ||
"eslint": "^6.4.0", | ||
"eslint-config-mourner": "^3.0.0", | ||
"tape": "^4.10.2" | ||
"tape": "^4.11.0" | ||
}, | ||
@@ -21,0 +21,0 @@ "scripts": { |
@@ -50,4 +50,5 @@ # pixelmatch | ||
- `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. `[255, 255, 0]` by default. | ||
- `diffColor` — The color of differing pixels in the diff output. `[255, 0, 0]` 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. | ||
- `diffMask` — Draw the diff over a transparent background (a mask), rather than over the original image. Will not draw anti-aliased pixels (if detected). | ||
@@ -70,3 +71,3 @@ Compares two images, writes the output diff and returns the number of mismatched pixels. | ||
const fs = require('fs'); | ||
const PNG = require('pngjs').PNG, | ||
const PNG = require('pngjs').PNG; | ||
const pixelmatch = require('pixelmatch'); | ||
@@ -79,3 +80,3 @@ | ||
pixelmatch(img1.data, img2.data, diff.data, img1.width, img1.height, {threshold: 0.1}); | ||
pixelmatch(img1.data, img2.data, diff.data, width, height, {threshold: 0.1}); | ||
@@ -88,9 +89,9 @@ fs.writeFileSync('diff.png', PNG.sync.write(diff)); | ||
```js | ||
const img1 = img1Ctx.getImageData(0, 0, width, height); | ||
const img2 = img2Ctx.getImageData(0, 0, width, height); | ||
const diff = diffCtx.createImageData(width, height); | ||
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}); | ||
diffCtx.putImageData(diff, 0, 0); | ||
diffContext.putImageData(diff, 0, 0); | ||
``` | ||
@@ -109,5 +110,5 @@ | ||
```html | ||
<script src="https://bundle.run/pixelmatch@5.0.1"></script> | ||
<script src="https://bundle.run/pixelmatch@5.0.2"></script> | ||
``` | ||
## [Changelog](https://github.com/mapbox/pixelmatch/releases) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15565
184
110