1.2.3 • Published 2 months ago

png-visual-compare v1.2.3

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Visual Regression Testing for PNGs in JavaScript/Typescript

Node.js utility to compare PNG images or their areas without binary and OS dependencies.

Tests on push

Description

This package exports single function comparePng which returns the number of mismatched pixels and optionally can create a diff PNG file.
Under the hood it uses pixelmatch lib for pixel-level image comparison.

Getting started

Installation:

npm install -D png-visual-compare

Example

test(`Compare PNG`, async () => {
    const compareResult: number =
      comparePng(
        img1, // First file path or Buffer to compare
        img2, // Second file path or Buffer to compare
        {
            excludedAreas // Areas list to exclude from comparing, default value is [].
            diffFilePath // File path where the differences file will be stored, default value is undefined.
            throwErrorOnInvalidInputData // Compare with empty file if set to false, default value is undefined. Will throw an exception if both files are invalid.
            pixelmatchOptions: // Pass options to Pixelmatch, default value is undefined.
        });

    expect(compareResult).toBe(0); // Number of mismatched pixels should be 0.

   ...
});

Buy Me A Coffee

In case you want support my work

"Buy Me A Coffee"

1.2.3

2 months ago

1.2.2

2 months ago

1.2.0

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.5.1

1 year ago

0.4.15

2 years ago

0.4.13

2 years ago

0.4.14

2 years ago

0.4.12

2 years ago

0.4.10

2 years ago

0.4.11

2 years ago

0.4.9

2 years ago

0.4.8

2 years ago

0.4.7

2 years ago

0.4.6

2 years ago

0.4.5

2 years ago

0.4.4

2 years ago

0.4.3

2 years ago

0.4.2

3 years ago

0.1.11

3 years ago

0.1.12

3 years ago

0.1.13

3 years ago

0.1.15

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.8

3 years ago

0.1.9

3 years ago

0.4.1

3 years ago

0.3.2

3 years ago

0.4.0

3 years ago

0.3.1

3 years ago

0.3.4

3 years ago

0.1.7

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.4

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago