Skip to content
This repository has been archived by the owner on Mar 18, 2024. It is now read-only.

NodeJs Version is super slow #15

Open
AlbertoBonfiglio opened this issue Mar 14, 2020 · 0 comments
Open

NodeJs Version is super slow #15

AlbertoBonfiglio opened this issue Mar 14, 2020 · 0 comments

Comments

@AlbertoBonfiglio
Copy link

Hi,
I have installed the latest version and the comparison between images works but it is very slow. On a i9700k 8 cores with 34gb takes 12 to 15 minutes to compare two images with the default settings.
THe same image comparison on the website is almost istantaneous leading me to believe it's a nodejs issue.
I am running nodejs 13.11 on ubuntu 19.10
this is my code :
'use strict';

/* eslint-disable max-len */
import Rembrandt from 'rembrandt/build/node.js';
....
async performAnalisys(session, files, threshold = 0.01, delta = 0.02, offset = 0, render = false) {
console.log('analisys', threshold, delta, offset, render);

	// this.processImages(session, data);
	const rembrandt = new Rembrandt({
		// `imageA` and `imageB` can be either Strings (file path on node.js, public url on Browsers) or Buffers
		imageA: `./uploads/${session}/${files[0].name}.png`,
		imageB: `./uploads/${session}/${files[1].name}.png`,
		// imageB: fs.readFileSync('/path/to/imageB'),
		thresholdType: Rembrandt.THRESHOLD_PERCENT, // either THRESHOLD_PERCENT or THRESHOLD_PIXELS
		maxThreshold: threshold, //  (0...1 for THRESHOLD_PERCENT, pixel count for THRESHOLD_PIXELS
		maxDelta: delta, // Maximum color delta (0...1):
		maxOffset: offset, // Maximum surrounding pixel offset
		renderComposition: render, // Should Rembrandt render a composition image?
		compositionMaskColor: Rembrandt.Color.RED // Color of unmatched pixels
	});

	const retVal = await rembrandt.compare()
		.then((result) => {
			console.log('Passed:', result.passed);
			console.log('Pixel Difference:', result.differences, 'Percentage Difference', result.percentageDifference, '%');
			console.log('Composition image buffer:', result.compositionImage);
			this.writeOutputFile(result.compositionImage);
			return result;
		})
		.catch((e) => console.error(e));

	return retVal;
}

Any helps or suggestion is appreciated

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant