https://github.com/kevincharm/equate
Node native module for simple image diffing.
https://github.com/kevincharm/equate
Last synced: 3 months ago
JSON representation
Node native module for simple image diffing.
- Host: GitHub
- URL: https://github.com/kevincharm/equate
- Owner: kevincharm
- License: apache-2.0
- Created: 2018-04-21T15:29:02.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-28T02:11:04.000Z (about 7 years ago)
- Last Synced: 2025-02-01T02:17:33.495Z (4 months ago)
- Language: C
- Homepage:
- Size: 615 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

# equate
Node native module for image diffing/comparison written in C. Requires `node@>=8.6.0` for N-API.
## Installation
Get it via npm:
```sh
npm install --save equate
```
or
```sh
yarn add equate
```## Usage
Plain JavaScript:
```js
const { isMatch } = require('equate')compare()
async function compare() {
const firstImage = fs.readFileSync('foo.jpg')
const secondImage = fs.readFileSync('foo.jpg')const result = await isMatch(firstImage, secondImage, {
tolerancePercent: 0,
diffOutputFormat: 'png'
})assert(result.didMatch, true)
}
```TypeScript (includes type definitions):
```ts
import { isMatch } from 'equate'compare()
async function compare() {
const firstImage = fs.readFileSync('foo.jpg')
const secondImage = fs.readFileSync('bar.jpg')const result = await isMatch(firstImage, secondImage, {
tolerancePercent: 0,
diffOutputFormat: 'png'
})const pngBuffer = result.imageDiffData
assert(pngBuffer.readUInt8(0), 0x89)
assert(result.didMatch, false)
}
```