# image-comparer

> Compare two image buffers in node

Latest version **1.1.3** (published 2017-07-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install image-comparer
pnpm add image-comparer
yarn add image-comparer
bun add image-comparer
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2017-07-16 |
| First published | 2017-02-05 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | louisbros |
| Keywords | image comparer, image compare, image diff, image comparison, image, diff, comparison, difference, pixel |

## Links

- npm: https://www.npmjs.com/package/image-comparer
- Repository: https://github.com/louisbros/image-comparer
- Homepage: https://github.com/louisbros/image-comparer#readme
- Issues: https://github.com/louisbros/image-comparer/issues
- npm.io page: https://npm.io/package/image-comparer

## Dependencies (3)

- [pngjs](https://npm.io/package/pngjs.md) 3.x.x
- [jpeg-js](https://npm.io/package/jpeg-js.md) 0.x.x
- [image-type](https://npm.io/package/image-type.md) 3.x.x

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 1.1.3 (latest) — 2017-07-16
- 1.1.2 — 2017-05-29
- 1.1.1 — 2017-05-29
- 1.1.0 — 2017-05-21
- 1.0.0 — 2017-04-23
- 0.0.5 — 2017-02-09
- 0.0.4 — 2017-02-07
- 0.0.3 — 2017-02-06
- 0.0.2 — 2017-02-05
- 0.0.1 — 2017-02-05

## README

# image-comparer

## Compare two image buffers in node

```js
import { ImageComparer, Processor, Comparator } from 'image-comparer';

ImageComparer.create()
    .withProcessor(Processor.MEAN_PIXEL())
    .withComparator(Comparator.RGBA_PCT(0.2))
    .compare(imgBufA, imgBufB)
    .then(comparison => {
        console.log(comparison.pct, comparison.bounds, comparison.time);
    });
```

### Processors

```js
PIXEL // an unprocessed pixel
MEAN_PIXEL // the mean of a 3*3 pixel neighbourhood
```

### Comparators

```js
RGBA_PCT(pct: number) // true if the percentage of difference between the RGBA values of two pixels is greater than the given pct
GREYSCALE_PCT(pct: number) // true if the percentage of difference between the greyscale value of two pixels is greater than the given pct
```

### Comparison

```js
{
    pct: number; // percentage of change
    bounds: { // bounds of change within image
        t: number;
        l: number;
        b: number;
        r: number;
    };
    time: number; // time taken to compare in millis
}
```

---
_Source: https://npm.io/package/image-comparer · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
