Browse Source

better compare for images of different sizes

pull/6/merge
James Cryer 12 years ago
parent
commit
36784309f3
  1. 18
      resemble.js

18
resemble.js

@ -405,6 +405,22 @@ URL: https://github.com/Huddle/Resemble.js
return barHeight;
}
function normalise(img, w, h){
var c;
var context;
if(img.height < h || img.width < w){
c = document.createElement('canvas');
c.width = w;
c.height = h;
context = c.getContext('2d');
context.putImageData(img, 0, 0);
return context.getImageData(0, 0, w, h);
}
return img;
}
function compare(one, two){
function onceWeHaveBoth(){
@ -420,7 +436,7 @@ URL: https://github.com/Huddle/Resemble.js
data.isSameDimensions = false;
}
analyseImages(images[0], images[1], width, height);
analyseImages( normalise(images[0],width, height), normalise(images[1],width, height), width, height);
triggerDataUpdate();
}

Loading…
Cancel
Save