# node-resemble-js

> Image analysis and comparison for nodejs

Latest version **0.2.0** (published 2016-11-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install node-resemble-js
pnpm add node-resemble-js
yarn add node-resemble-js
bun add node-resemble-js
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2016-11-24 |
| First published | 2014-09-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 99 |
| Author | Lukas Svoboda |
| Maintainers | lksv |
| Keywords | comparison, image, diff, compare |

## Links

- npm: https://www.npmjs.com/package/node-resemble-js
- Repository: https://github.com/lksv/node-resemble.js
- Issues: https://github.com/lksv/node-resemble.js/issues
- npm.io page: https://npm.io/package/node-resemble-js

## Dependencies (2)

- [pngjs](https://npm.io/package/pngjs.md) ~2.2.0
- [jpeg-js](https://npm.io/package/jpeg-js.md) 0.2.0

## 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

- 0.2.0 (latest) — 2016-11-24
- 0.1.1 — 2016-08-09
- 0.0.5 — 2016-01-12
- 0.0.4 — 2014-09-19

## README

node-resemble.js
================

Analyse and compare images with Javascript. This project does not need canvas or any other binary denpendencies.
It is a modification of [Resemble.js](https://github.com/Huddle/Resemble.js)


### Get it

`npm install node-resemble-js`

### Example

Retrieve basic analysis on image.

```javascript
var api = resemble(fileData).onComplete(function(data){
	console.log(data);
	/*
	{
	  red: 255,
	  green: 255,
	  blue: 255,
	  brightness: 255
	}
	*/
});
```

Use resemble to compare two images.

```javascript
var diff = resemble(file).compareTo(file2).ignoreColors().onComplete(function(data){
	console.log(data);
	/*
	{
	  misMatchPercentage : 100, // %
	  isSameDimensions: true, // or false
	  dimensionDifference: { width: 0, height: -1 }, // defined if dimensions are not the same
	  getImageDataUrl: function(){}
	}
	*/
});
```

You can also change the comparison method after the first analysis.

```javascript
// diff.ignoreNothing();
// diff.ignoreColors();
diff.ignoreAntialiasing();
```

And change the output display style.

```javascript
resemble.outputSettings({
  errorColor: {
    red: 255,
    green: 0,
    blue: 255
  },
  errorType: 'movement',
  transparency: 0.3
});
// resembleControl.repaint();
```

--------------------------------------
## Example usuage (in cucumber step definition)


     this.Then(/^Screenshot should match image "(.*)"$/, function (image, callback) {
        browser.takeScreenshot().then(function(pngString) {
          var screenshot = new Buffer(pngString, 'base64');
     
          resemble(image)
            .compareTo(screenshot)
            .onComplete(function(data){
     
              if (Number(data.misMatchPercentage) <= 0.01) {
                callback();
              } else {
                data.getDiffImage().pack().pipe(fs.createWriteStream(image + 'diff.png'));
                callback.fail(new Error("Screenshot '" + image+  "' differ " + data.misMatchPercentage + "%"));
              }
            });
        });
      })

--------------------------------------

Credits:
 * Created by [James Cryer](http://github.com/jamescryer) and the Huddle development team.
 * [Lukas Svoboda](http://github.com/lksv) - modification for node.js

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