|
|
|
@ -23,6 +23,17 @@ URL: https://github.com/Huddle/Resemble.js
|
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var oldOutputSettings = {}; |
|
|
|
|
var globalOutputSettings = oldOutputSettings; |
|
|
|
|
|
|
|
|
|
function setGlobalOutputSettings(settings) { |
|
|
|
|
var msg = 'warning resemble.outputSettings mutates global state, and ' + |
|
|
|
|
'will be removed in 3.0.0'; |
|
|
|
|
console.error(msg); |
|
|
|
|
globalOutputSettings = settings; |
|
|
|
|
return this |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var resemble = function( fileData ){ |
|
|
|
|
var pixelTransparency = 1; |
|
|
|
|
|
|
|
|
@ -586,40 +597,6 @@ URL: https://github.com/Huddle/Resemble.js
|
|
|
|
|
return img; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function compare(one, two){ |
|
|
|
|
|
|
|
|
|
function onceWeHaveBoth(){ |
|
|
|
|
var width; |
|
|
|
|
var height; |
|
|
|
|
if(images.length === 2){ |
|
|
|
|
if( images[0].error || images[1].error ){ |
|
|
|
|
data = {}; |
|
|
|
|
data.error = images[0].error ? images[0].error : images[1].error; |
|
|
|
|
triggerDataUpdate(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
width = images[0].width > images[1].width ? images[0].width : images[1].width; |
|
|
|
|
height = images[0].height > images[1].height ? images[0].height : images[1].height; |
|
|
|
|
|
|
|
|
|
if( (images[0].width === images[1].width) && (images[0].height === images[1].height) ){ |
|
|
|
|
data.isSameDimensions = true; |
|
|
|
|
} else { |
|
|
|
|
data.isSameDimensions = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
data.dimensionDifference = { width: images[0].width - images[1].width, height: images[0].height - images[1].height }; |
|
|
|
|
|
|
|
|
|
analyseImages( normalise(images[0],width, height), normalise(images[1],width, height), width, height); |
|
|
|
|
|
|
|
|
|
triggerDataUpdate(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
images = []; |
|
|
|
|
loadImageData(one, onceWeHaveBoth); |
|
|
|
|
loadImageData(two, onceWeHaveBoth); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function outputSettings(options){ |
|
|
|
|
var key; |
|
|
|
|
var undefined; |
|
|
|
@ -655,6 +632,43 @@ URL: https://github.com/Huddle/Resemble.js
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function compare(one, two){ |
|
|
|
|
if (globalOutputSettings !== oldGlobalSettings) { |
|
|
|
|
outputSettings(options); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function onceWeHaveBoth(){ |
|
|
|
|
var width; |
|
|
|
|
var height; |
|
|
|
|
if(images.length === 2){ |
|
|
|
|
if( images[0].error || images[1].error ){ |
|
|
|
|
data = {}; |
|
|
|
|
data.error = images[0].error ? images[0].error : images[1].error; |
|
|
|
|
triggerDataUpdate(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
width = images[0].width > images[1].width ? images[0].width : images[1].width; |
|
|
|
|
height = images[0].height > images[1].height ? images[0].height : images[1].height; |
|
|
|
|
|
|
|
|
|
if( (images[0].width === images[1].width) && (images[0].height === images[1].height) ){ |
|
|
|
|
data.isSameDimensions = true; |
|
|
|
|
} else { |
|
|
|
|
data.isSameDimensions = false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
data.dimensionDifference = { width: images[0].width - images[1].width, height: images[0].height - images[1].height }; |
|
|
|
|
|
|
|
|
|
analyseImages( normalise(images[0],width, height), normalise(images[1],width, height), width, height); |
|
|
|
|
|
|
|
|
|
triggerDataUpdate(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
images = []; |
|
|
|
|
loadImageData(one, onceWeHaveBoth); |
|
|
|
|
loadImageData(two, onceWeHaveBoth); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function getCompareApi(param){ |
|
|
|
|
|
|
|
|
|
var secondFileData, |
|
|
|
@ -784,7 +798,7 @@ URL: https://github.com/Huddle/Resemble.js
|
|
|
|
|
}, |
|
|
|
|
compareTo: function(secondFileData){ |
|
|
|
|
return getCompareApi(secondFileData); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
outputSettings: function(options) { |
|
|
|
|
outputSettings(options); |
|
|
|
|
return rootSelf; |
|
|
|
@ -837,5 +851,6 @@ URL: https://github.com/Huddle/Resemble.js
|
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
resemble.outputSettings = setGlobalOutputSettings; |
|
|
|
|
return resemble; |
|
|
|
|
})); |
|
|
|
|