@@ -47,8 +47,8 @@ Implements ideas from the following papers:
4747- ` threshold ` — Matching threshold, ranges from ` 0 ` to ` 1 ` . Smaller values make the comparison more sensitive. ` 0.1 ` by default.
4848- ` includeAA ` — If ` true ` , disables detecting and ignoring anti-aliased pixels. ` false ` by default.
4949- ` 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.
50- - ` aaColor ` — The color of anti-aliased pixels in the diff output. ` [255, 255, 0] ` by default.
51- - ` diffColor ` — The color of differing pixels in the diff output. ` [255, 0, 0] ` by default.
50+ - ` aaColor ` — The color of anti-aliased pixels in the diff output in ` [R, G, B] ` format . ` [255, 255, 0] ` by default.
51+ - ` diffColor ` — The color of differing pixels in the diff output in ` [R, G, B] ` format . ` [255, 0, 0] ` by default.
5252
5353Compares two images, writes the output diff and returns the number of mismatched pixels.
5454
@@ -74,21 +74,21 @@ const img2 = PNG.sync.read(fs.readFileSync('img2.png'));
7474const {width , height } = img1;
7575const diff = new PNG ({width, height});
7676
77- pixelmatch (img1 .data , img2 .data , diff .data , img1 . width , img1 . height , {threshold: 0.1 });
77+ pixelmatch (img1 .data , img2 .data , diff .data , width, height, {threshold: 0.1 });
7878
7979fs .writeFileSync (' diff.png' , PNG .sync .write (diff));
8080```
8181
8282### Browsers
8383
8484``` js
85- const img1 = img1Ctx .getImageData (0 , 0 , width, height);
86- const img2 = img2Ctx .getImageData (0 , 0 , width, height);
87- const diff = diffCtx .createImageData (width, height);
85+ const img1 = img1Context .getImageData (0 , 0 , width, height);
86+ const img2 = img2Context .getImageData (0 , 0 , width, height);
87+ const diff = diffContext .createImageData (width, height);
8888
8989pixelmatch (img1 .data , img2 .data , diff .data , width, height, {threshold: 0.1 });
9090
91- diffCtx .putImageData (diff, 0 , 0 );
91+ diffContext .putImageData (diff, 0 , 0 );
9292```
9393
9494## Install
@@ -102,7 +102,7 @@ npm install pixelmatch
102102Use in the browser from a CDN:
103103
104104``` html
105- <script src =" https://bundle.run/pixelmatch@5.0.1 " ></script >
105+ <script src =" https://bundle.run/pixelmatch@5.0.2 " ></script >
106106```
107107
108108## [ Changelog] ( https://github.com/mapbox/pixelmatch/releases )
0 commit comments