diff --git a/README.md b/README.md index a40312f..4e71e56 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,12 @@ var diff = resemble(file).compareTo(file2).ignoreColors().onComplete(function(da }); ``` +Scale second image to dimensions of the first one: +```javascript +//diff.useOriginalSize(); +diff.scaleToSameSize(); +``` + You can also change the comparison method after the first analysis. ```javascript @@ -53,6 +59,7 @@ You can also change the comparison method after the first analysis. diff.ignoreAntialiasing(); ``` + And change the output display style. ```javascript diff --git a/demoassets/main.js b/demoassets/main.js index dfa5b89..96085dd 100644 --- a/demoassets/main.js +++ b/demoassets/main.js @@ -115,6 +115,14 @@ $(function(){ resembleControl.ignoreAntialiasing(); } else + if($this.is('#same-size')){ + resembleControl.scaleToSameSize(); + } + else + if($this.is('#original-size')){ + resembleControl.useOriginalSize(); + } + else if($this.is('#pink')){ resemble.outputSettings({ errorColor: { diff --git a/index.html b/index.html index c266060..d24148c 100644 --- a/index.html +++ b/index.html @@ -91,6 +91,13 @@ +
+
+ +

diff --git a/package.json b/package.json index 580d938..f350e11 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "resemblejs", - "version": "2.1.0", + "version": "2.1.1", "description": "Image analysis and comparison with HTML5", "main": "resemble.js", "repository": { diff --git a/resemble.js b/resemble.js index e8f2ea9..d124c24 100644 --- a/resemble.js +++ b/resemble.js @@ -88,6 +88,7 @@ URL: https://github.com/Huddle/Resemble.js var ignoreAntialiasing = false; var ignoreColors = false; + var scaleToSameSize = false; function triggerDataUpdate(){ var len = updateCallbackArray.length; @@ -165,6 +166,12 @@ URL: https://github.com/Huddle/Resemble.js var hiddenCanvas = document.createElement('canvas'); var imageData; + + if( scaleToSameSize && images.length == 1 ){ + hiddenImage.width = images[0].width; + hiddenImage.height = images[0].height; + } + var width = hiddenImage.width; var height = hiddenImage.height; @@ -584,6 +591,18 @@ URL: https://github.com/Huddle/Resemble.js } var self = { + scaleToSameSize: function(){ + scaleToSameSize = true; + + if(hasMethod) { param(); } + return self; + }, + useOriginalSize: function(){ + scaleToSameSize = false; + + if(hasMethod) { param(); } + return self; + }, ignoreNothing: function(){ tolerance.red = 0;