odiff-bin
Version:
The fastest image difference tool in the world
54 lines (51 loc) • 1.73 kB
TypeScript
export type ODiffOptions = Partial<{
/** Color used to highlight different pixels in the output (in hex format e.g. #cd2cc9). */
diffColor: string;
/** Output full diff image. */
outputDiffMask: boolean;
/** Do not compare images and produce output if images layout is different. */
failOnLayoutDiff: boolean;
/** Return { match: false, reason: '...' } instead of throwing error if file is missing. */
noFailOnFsErrors: boolean;
/** Color difference threshold (from 0 to 1). Less more precise. */
threshold: number;
/** If this is true, antialiased pixels are not counted to the diff of an image */
antialiasing: boolean;
/** If `true` reason: "pixel-diff" output will contain the set of line indexes containing different pixels */
captureDiffLines: boolean;
/** If `true` odiff will use less memory but will be slower with larger images */
reduceRamUsage: boolean;
/** An array of regions to ignore in the diff. */
ignoreRegions: Array<{
x1: number;
y1: number;
x2: number;
y2: number;
}>;
}>;
declare function compare(
basePath: string,
comparePath: string,
diffPath: string,
options?: ODiffOptions
): Promise<
| { match: true }
| { match: false; reason: "layout-diff" }
| {
match: false;
reason: "pixel-diff";
/** Amount of different pixels */
diffCount: number;
/** Percentage of different pixels in the whole image */
diffPercentage: number;
/** Individual line indexes containing different pixels. Guaranteed to be ordered and distinct. */
diffLines?: number[];
}
| {
match: false;
reason: "file-not-exists";
/** Errored file path */
file: string;
}
>;
export { compare };