From 531ca66d8d90842a1cad74bd393ad0b6499c166d Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Wed, 17 Jan 2018 17:53:54 +0000 Subject: [PATCH 1/2] Revert "restore global settings function" This reverts commit e5424ce1e5ced98aca7dc3c17ecde9479ff8784d. --- resemble.js | 85 ++++++++++++++++++++++------------------------------- 1 file changed, 35 insertions(+), 50 deletions(-) diff --git a/resemble.js b/resemble.js index 44d359c..73933a5 100644 --- a/resemble.js +++ b/resemble.js @@ -23,17 +23,6 @@ URL: https://github.com/Huddle/Resemble.js } }; - var oldGlobalSettings = {}; - var globalOutputSettings = oldGlobalSettings; - - function setGlobalOutputSettings(settings) { - var msg = 'warning resemble.outputSettings mutates global state, and ' + - 'will be removed in 3.0.0'; - console.warn(msg); - globalOutputSettings = settings; - return this - } - var resemble = function( fileData ){ var pixelTransparency = 1; @@ -596,6 +585,40 @@ 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; @@ -631,43 +654,6 @@ 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, @@ -797,7 +783,7 @@ URL: https://github.com/Huddle/Resemble.js }, compareTo: function(secondFileData){ return getCompareApi(secondFileData); - }, + } outputSettings: function(options) { outputSettings(options); return rootSelf; @@ -852,6 +838,5 @@ URL: https://github.com/Huddle/Resemble.js }); }; - resemble.outputSettings = setGlobalOutputSettings; return resemble; })); From 94a06888b3065c3148244b129d081c951502db99 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Fri, 13 Mar 2020 00:10:09 +0000 Subject: [PATCH 2/2] Update resemble.js Co-Authored-By: Christopher Carman --- resemble.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resemble.js b/resemble.js index 73933a5..f8ccb42 100644 --- a/resemble.js +++ b/resemble.js @@ -783,7 +783,7 @@ URL: https://github.com/Huddle/Resemble.js }, compareTo: function(secondFileData){ return getCompareApi(secondFileData); - } + }, outputSettings: function(options) { outputSettings(options); return rootSelf;