{"_id":"pixelmatch@8.0.0","bin":{"pixelmatch":"bin/pixelmatch"},"bugs":{"url":"https://github.com/mapbox/pixelmatch/issues"},"dist":{"shasum":"e1aeaa0b6e52b87603e0a6e8ae35687e1550a143","tarball":"http://registry-npm.ywwl.com/pixelmatch/download/pixelmatch-8.0.0.tgz","fileCount":6,"integrity":"sha512-cIqOLfh5k52us715qf3B3+kTOxZv+WDv77HN7xokLScYQGYQHi4m/ynoDIPpvF2LvCyUJGyvzY64i0QCXtzu1g==","signatures":[{"sig":"MEQCIEEVBflwp7Y5g7APd6gCXRTtaWSJv4e1dAWK2nmAhsGNAiAMDPGM6Gylf3l5WwLMDtuEqKyAyvTiz2YYCBElYAzjzQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDyrLbbiZkm2lT5qd8Iaz5s3py7TDisxMhCmc+THw7MLAIgWWtSoDujDZXq5eZrO/G6RQBQ16mGJJe0GGZe7O2lhvc="}],"unpackedSize":36795,"size":11984,"noattachment":false,"key":"/pixelmatch/-/pixelmatch-8.0.0.tgz"},"main":"index.js","name":"pixelmatch","type":"module","types":"index.d.ts","author":{"name":"Volodymyr Agafonkin"},"gitHead":"bddb61314b2db3ad7e6f1ec57b38bf2dbae81184","license":"ISC","scripts":{"test":"tsc && node --test","pretest":"eslint"},"version":"8.0.0","_npmUser":{"name":"mourner","email":"agafonkin@gmail.com"},"homepage":"https://github.com/mapbox/pixelmatch#readme","keywords":["image","comparison","diff"],"repository":{"url":"git+https://github.com/mapbox/pixelmatch.git","type":"git"},"_npmVersion":"12.1.0","description":"The smallest and fastest pixel-level image comparison library.","directories":{},"maintainers":[{"name":"mapbox-npm-01","email":"accounts+npmjs-01@mapbox.com"},{"name":"mapbox-npm-02","email":"accounts+npmjs-02@mapbox.com"},{"name":"mapbox-npm-07","email":"accounts+npmjs-07@mapbox.com"},{"name":"mapbox-npm-03","email":"accounts+npmjs-03@mapbox.com"},{"name":"mapbox-npm-04","email":"accounts+npmjs-04@mapbox.com"},{"name":"mapbox-npm-09","email":"accounts+npmjs-09@mapbox.com"},{"name":"mapbox-npm-05","email":"accounts+npmjs-05@mapbox.com"},{"name":"mapbox-npm-06","email":"accounts+npmjs-06@mapbox.com"},{"name":"mapbox-npm-08","email":"accounts+npmjs-08@mapbox.com"},{"name":"mapbox-npm-advanced-actions","email":"accounts+npmjs-advanced-actions@mapbox.com"},{"name":"mapbox-npm-ci","email":"accounts+npmjs-npm-ci@mapbox.com"},{"name":"mapbox-npm","email":"accounts+npmjs@mapbox.com"},{"name":"mapbox-admin","email":"accounts@mapbox.com"},{"name":"mapbox-machine-user","email":"accounts+npm-mapbox-machine-user@mapbox.com"},{"name":"mbx-npm-ci-staging","email":"yannick.meeus+npm+staging+ci@mapbox.com"},{"name":"mbx-npm-ci-production","email":"yannick.meeus+npm+production+ci@mapbox.com"},{"name":"mbx-npm-01-production","email":"yannick.meeus+npm+prod+01@mapbox.com"},{"name":"mbx-npm-02-production","email":"yannick.meeus+npm+prod+02@mapbox.com"},{"name":"mbx-npm-03-production","email":"yannick.meeus+npm+prod+03@mapbox.com"},{"name":"mbx-npm-04-production","email":"yannick.meeus+npm+prod+04@mapbox.com"},{"name":"mbx-npm-05-production","email":"yannick.meeus+npm+prod+05@mapbox.com"},{"name":"mbx-npm-06-production","email":"yannick.meeus+npm+prod+06@mapbox.com"},{"name":"mbx-npm-07-production","email":"yannick.meeus+npm+prod+07@mapbox.com"},{"name":"mbx-npm-08-production","email":"yannick.meeus+npm+prod+08@mapbox.com"},{"name":"mbx-npm-09-production","email":"yannick.meeus+npm+prod+09@mapbox.com"},{"name":"mbx-npm-02-staging","email":"yannick.meeus@mapbox.com"},{"name":"mbx-npm-advanced-actions-staging","email":"yannick.meeus+npm+staging+advanced+actions@mapbox.com"},{"name":"mbx-npm-advanced-actions-production","email":"yannick.meeus+npm+prod+advanced+actions@mapbox.com"},{"name":"mourner","email":"agafonkin@gmail.com"}],"_nodeVersion":"24.21.0","dependencies":{"pngjs":"^7.0.0"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^10.2.1","typescript":"^6.0.3","eslint-config-mourner":"^4.1.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pixelmatch_8.0.0_1791278063816_0.8955242013591131"},"readme":"# pixelmatch\n\n[![Node](https://github.com/mapbox/pixelmatch/actions/workflows/node.yml/badge.svg)](https://github.com/mapbox/pixelmatch/actions/workflows/node.yml)\n[![](https://img.shields.io/badge/simply-awesome-brightgreen.svg)](https://github.com/mourner/projects)\n\nA small, simple and fast JavaScript pixel-level **image comparison library**,\noriginally created to compare screenshots in tests.\n\nFeatures accurate **anti-aliased pixels detection** and **perceptual color difference** metrics.\nInspired by [Resemble.js](https://github.com/Huddle/Resemble.js)\nand [Blink-diff](https://github.com/yahoo/blink-diff).\nUnlike these libraries, pixelmatch is just **a few hundred lines of code**,\nhas **no dependencies**, and works on **raw typed arrays** of image data,\nso it's **very fast** and can be used in both Node and browsers.\n\n```js\nconst numDiffPixels = pixelmatch(img1, img2, diff, 800, 600, {threshold: 0.1});\n```\n\nImplements ideas from the following papers:\n\n- [A perceptual color space for image processing](https://bottosson.github.io/posts/oklab/) (2020, Björn Ottosson) — the OKLab color space used for color difference.\n- [Distance metrics for very large color differences](https://onlinelibrary.wiley.com/doi/10.1002/col.22451) (2019, Saeideh Abasi et al.) — the OKLab HyAB metric used to compare colors.\n- [Anti-aliased pixel and intensity slope detector](https://www.researchgate.net/publication/234126755_Anti-aliased_Pixel_and_Intensity_Slope_Detector) (2009, Vytautas Vyšniauskas)\n\n## [Demo](https://observablehq.com/@mourner/pixelmatch-demo)\n\n## Example output\n\n| expected | actual | diff |\n| --- | --- | --- |\n| ![](test/fixtures/4a.png) | ![](test/fixtures/4b.png) | ![1diff](test/fixtures/4diff.png) |\n| ![](test/fixtures/3a.png) | ![](test/fixtures/3b.png) | ![1diff](test/fixtures/3diff.png) |\n| ![](test/fixtures/6a.png) | ![](test/fixtures/6b.png) | ![1diff](test/fixtures/6diff.png) |\n\n## API\n\n### pixelmatch(img1, img2, output, width, height[, options])\n\n- `img1`, `img2` — Image data of the images to compare (`Buffer`, `Uint8Array` or `Uint8ClampedArray`). **Note:** image dimensions must be equal.\n- `output` — Image data to write the diff to, or `null` if don't need a diff image.\n- `width`, `height` — Width and height of the images. Note that _all three images_ need to have the same dimensions.\n\n`options` is an object literal with the following properties:\n\n- `threshold` — How different two colors must be for a pixel to count as mismatched, from `0` to `1`. It's a per-pixel perceptual color difference, where `1` is the difference between black and white, not a share of the image; to allow some percentage of the image to differ, compare the returned count against `width * height` instead. Smaller values make the comparison more sensitive. `0.1` by default.\n- `includeAA` — If `true`, disables detecting and ignoring anti-aliased pixels. `false` by default.\n- `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.\n- `aaColor` — The color of anti-aliased pixels in the diff output in `[R, G, B]` format. `[255, 255, 0]` by default.\n- `diffColor` — The color of differing pixels in the diff output in `[R, G, B]` format. `[255, 0, 0]` by default.\n- `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.\n- `diffMask` — Draw the diff over a transparent background (a mask), rather than over the original image. Will not draw anti-aliased pixels (if detected).\n- `checkerboard` — Blend semi-transparent pixels against a checkerboard pattern when comparing (`true`) rather than plain white (`false`), avoiding false matches between colors that only look alike over one background. `true` by default.\n- `windowSize` — If set to a finite number `N`, return the maximum number of differing pixels in any `N`×`N` sliding window instead of the total count (see below). `Infinity` by default.\n- `ignoreMask` — A `Uint8Array`, `Uint8ClampedArray` or `Buffer` with one value per pixel (`width * height` long); pixels with a non-zero value are excluded from the comparison and drawn as unchanged in the diff output. Not set by default.\n\nCompares two images, writes the output diff and returns the number of mismatched pixels.\n\n### Windowed diff counts\n\nNormally the return value is the total number of differing pixels. With `windowSize: N` you get the\nhighest number of diff pixels in any `N`×`N` square instead. Anti-aliased pixels are only included\nif `includeAA` is `true`.\n\nThis helps with noise. GPU dithering and sub-pixel anti-aliasing scatter stray pixels all over the\nimage, so they never fill up one small square, while a real regression usually changes a compact\narea.\n\nCompare the result against a pixel count: that number is how big a difference you let through, and\n`N` is how closely packed it has to be.\n\n```js\nif (pixelmatch(img1, img2, null, width, height, {windowSize: 16}) > 28) throw new Error('changed');\n```\n\n`N` never exceeds either image dimension, so on a 10×2 image `windowSize: 32` gives you a 2×2\nwindow. The default `Infinity` makes the window the whole image, which is the total count.\n\n## Command line\n\nPixelmatch comes with a binary that works with PNG images:\n\n```bash\npixelmatch image1.png image2.png output.png 0.1\n```\n\n## Example usage\n\n### Node.js\n\n```js\nimport fs from 'fs';\nimport {PNG} from 'pngjs';\nimport pixelmatch from 'pixelmatch';\n\nconst img1 = PNG.sync.read(fs.readFileSync('img1.png'));\nconst img2 = PNG.sync.read(fs.readFileSync('img2.png'));\nconst {width, height} = img1;\nconst diff = new PNG({width, height});\n\npixelmatch(img1.data, img2.data, diff.data, width, height, {threshold: 0.1});\n\nfs.writeFileSync('diff.png', PNG.sync.write(diff));\n```\n\n### Browsers\n\n```js\nconst img1 = img1Context.getImageData(0, 0, width, height);\nconst img2 = img2Context.getImageData(0, 0, width, height);\nconst diff = diffContext.createImageData(width, height);\n\npixelmatch(img1.data, img2.data, diff.data, width, height, {threshold: 0.1});\n\ndiffContext.putImageData(diff, 0, 0);\n```\n\n## Install\n\nInstall with NPM:\n\n```bash\nnpm install pixelmatch\n```\n\nOr use in the browser from a CDN:\n\n```html\n<script type=\"module\">\n\timport pixelmatch from 'https://esm.run/pixelmatch';\n```\n\n## [Changelog](https://github.com/mapbox/pixelmatch/releases)\n","publish_time":1791278063921,"_cnpm_publish_time":1791278063921,"dist-tags":{"latest":"8.0.0"}}