node-resemble.js
Advanced tools
@@ -28,5 +28,6 @@ var resemble = require('../resemble.js'); | ||
//.ignoreColors() | ||
.ignoreRectangles([[325,170,100,40]]) | ||
.onComplete(function(data){ | ||
console.log(data); | ||
data.getDiffImage().pack().pipe(fs.createWriteStream('diff.png')); | ||
console.log('with ignore rectangle:', data); | ||
data.getDiffImage().pack().pipe(fs.createWriteStream('diffr.png')); | ||
}); |
{ | ||
"name": "node-resemble.js", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Image analysis and comparison for nodejs", | ||
@@ -5,0 +5,0 @@ "main": "resemble.js", |
@@ -62,2 +62,3 @@ /* | ||
var ignoreColors = false; | ||
var ignoreRectangles = null; | ||
@@ -125,3 +126,2 @@ function triggerDataUpdate(){ | ||
.on('parsed', function() { | ||
console.log('image parsed, name:', fileData); | ||
callback(this, this.width, this.height); | ||
@@ -342,2 +342,5 @@ }); | ||
var currentRectangle = null; | ||
var rectagnlesIdx = 0; | ||
if( (width > 1200 || height > 1200) && ignoreAntialiasing){ | ||
@@ -363,2 +366,19 @@ skip = 6; | ||
if (ignoreRectangles) { | ||
for(rectagnlesIdx = 0; rectagnlesIdx < ignoreRectangles.length; rectagnlesIdx++) { | ||
currentRectangle = ignoreRectangles[rectagnlesIdx]; | ||
//console.log(currentRectangle, verticalPos, horizontalPos); | ||
if ( | ||
(verticalPos >= currentRectangle[1]) && | ||
(verticalPos < currentRectangle[1] + currentRectangle[3]) && | ||
(horizontalPos >= currentRectangle[0]) && | ||
(horizontalPos < currentRectangle[0] + currentRectangle[2]) | ||
) { | ||
copyGrayScalePixel(targetPix, offset, pixel2); | ||
//copyPixel(targetPix, offset, pixel1, pixel2); | ||
return; | ||
} | ||
} | ||
} | ||
if (ignoreColors){ | ||
@@ -493,2 +513,8 @@ | ||
}, | ||
//array of rectangles, each rectangle is defined as (x, y, width. height) | ||
//e.g. [[325, 170, 100, 40]] | ||
ignoreRectangles: function(rectangles) { | ||
ignoreRectangles = rectangles; | ||
return self; | ||
}, | ||
repaint: function(){ | ||
@@ -495,0 +521,0 @@ if(hasMethod) { param(); } |
482
5.47%629481
-25.98%