resemblejs
Advanced tools
Comparing version 1.1.3 to 1.2.0
{ | ||
"name": "resemblejs", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"description": "Image analysis and comparison with HTML5", | ||
@@ -5,0 +5,0 @@ "main": "resemble.js", |
@@ -18,2 +18,6 @@ /* | ||
function colorsDistance(c1, c2){ | ||
return (Math.abs(c1.r - c2.r) + Math.abs(c1.g - c2.g) + Math.abs(c1.b - c2.b))/3; | ||
} | ||
var errorPixelTransform = { | ||
@@ -35,2 +39,19 @@ flat : function (d1, d2){ | ||
} | ||
}, | ||
flatDifferenceIntensity: function (d1, d2){ | ||
return { | ||
r: errorPixelColor.red, | ||
g: errorPixelColor.green, | ||
b: errorPixelColor.blue, | ||
a: colorsDistance(d1, d2) | ||
} | ||
}, | ||
movementDifferenceIntensity: function (d1, d2){ | ||
var ratio = colorsDistance(d1, d2)/255 * 0.8; | ||
return { | ||
r: ((1-ratio)*(d2.r*(errorPixelColor.red/255)) + ratio*errorPixelColor.red), | ||
g: ((1-ratio)*(d2.g*(errorPixelColor.green/255)) + ratio*errorPixelColor.green), | ||
b: ((1-ratio)*(d2.b*(errorPixelColor.blue/255)) + ratio*errorPixelColor.blue), | ||
a: d2.a | ||
} | ||
} | ||
@@ -42,2 +63,5 @@ }; | ||
var largeImageThreshold = 1200; | ||
var httpRegex = /^https?:\/\//; | ||
var documentDomainRegex = new RegExp('^https?://' + document.domain); | ||
@@ -116,3 +140,6 @@ _this['resemble'] = function( fileData ){ | ||
var hiddenImage = new Image(); | ||
hiddenImage.setAttribute("crossOrigin", "crossOrigin"); | ||
if (httpRegex.test(fileData) && !documentDomainRegex.test(fileData)) { | ||
hiddenImage.setAttribute('crossorigin', 'anonymous'); | ||
} | ||
@@ -138,2 +165,5 @@ hiddenImage.onload = function() { | ||
hiddenImage.src = fileData; | ||
if (hiddenImage.complete) { | ||
hiddenImage.onload(); | ||
} | ||
} else if (typeof fileData.data !== 'undefined' | ||
@@ -140,0 +170,0 @@ && typeof fileData.width === 'number' |
18585
505