equate
v3.1.0
Published
Node native module for image diffing/comparison written in C
Downloads
2
Maintainers
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:
npm install --save equate
or
yarn add equate
Usage
Plain JavaScript:
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):
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)
}