Browse Source

add new comparison option "scaleToSameSize"

pull/60/head
Anton Sivolapov 9 years ago
parent
commit
15d2b12d08
  1. 7
      README.md
  2. 8
      demoassets/main.js
  3. 7
      index.html
  4. 19
      resemble.js

7
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

8
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: {

7
index.html

@ -91,6 +91,13 @@
<button class="btn" id="antialising">Ignore antialiasing</button>
</div>
<br/>
<br/>
<div class="btn-group buttons" style="display:none">
<button class="btn active" id="original-size">Use original size</button>
<button class="btn" id="same-size">Scale to same size</button>
</div>
<br/>
<br/>

19
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;

Loading…
Cancel
Save