image-comparer
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

image-comparer

Compare two image buffers in node

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

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

Comparators

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

{
    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
}

Package Sidebar

Install

npm i image-comparer

Weekly Downloads

2

Version

1.1.3

License

MIT

Last publish

Collaborators

  • louisbros