Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

image-comparer

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
}

install

npm i image-comparer

Downloadsweekly downloads

30

version

1.1.3

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar