Browse Source

Merge pull request #60 from c301/feature-scale

Feature scale
pull/63/head
James Cryer 9 years ago
parent
commit
f8893a5c0f
  1. 7
      README.md
  2. 8
      demoassets/main.js
  3. 7
      index.html
  4. 2
      package.json
  5. 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. You can also change the comparison method after the first analysis.
```javascript ```javascript
@ -53,6 +59,7 @@ You can also change the comparison method after the first analysis.
diff.ignoreAntialiasing(); diff.ignoreAntialiasing();
``` ```
And change the output display style. And change the output display style.
```javascript ```javascript

8
demoassets/main.js

@ -115,6 +115,14 @@ $(function(){
resembleControl.ignoreAntialiasing(); resembleControl.ignoreAntialiasing();
} }
else else
if($this.is('#same-size')){
resembleControl.scaleToSameSize();
}
else
if($this.is('#original-size')){
resembleControl.useOriginalSize();
}
else
if($this.is('#pink')){ if($this.is('#pink')){
resemble.outputSettings({ resemble.outputSettings({
errorColor: { errorColor: {

7
index.html

@ -91,6 +91,13 @@
<button class="btn" id="antialising">Ignore antialiasing</button> <button class="btn" id="antialising">Ignore antialiasing</button>
</div> </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/>
<br/> <br/>

2
package.json

@ -1,6 +1,6 @@
{ {
"name": "resemblejs", "name": "resemblejs",
"version": "2.1.0", "version": "2.1.1",
"description": "Image analysis and comparison with HTML5", "description": "Image analysis and comparison with HTML5",
"main": "resemble.js", "main": "resemble.js",
"repository": { "repository": {

19
resemble.js

@ -88,6 +88,7 @@ URL: https://github.com/Huddle/Resemble.js
var ignoreAntialiasing = false; var ignoreAntialiasing = false;
var ignoreColors = false; var ignoreColors = false;
var scaleToSameSize = false;
function triggerDataUpdate(){ function triggerDataUpdate(){
var len = updateCallbackArray.length; var len = updateCallbackArray.length;
@ -165,6 +166,12 @@ URL: https://github.com/Huddle/Resemble.js
var hiddenCanvas = document.createElement('canvas'); var hiddenCanvas = document.createElement('canvas');
var imageData; var imageData;
if( scaleToSameSize && images.length == 1 ){
hiddenImage.width = images[0].width;
hiddenImage.height = images[0].height;
}
var width = hiddenImage.width; var width = hiddenImage.width;
var height = hiddenImage.height; var height = hiddenImage.height;
@ -584,6 +591,18 @@ URL: https://github.com/Huddle/Resemble.js
} }
var self = { var self = {
scaleToSameSize: function(){
scaleToSameSize = true;
if(hasMethod) { param(); }
return self;
},
useOriginalSize: function(){
scaleToSameSize = false;
if(hasMethod) { param(); }
return self;
},
ignoreNothing: function(){ ignoreNothing: function(){
tolerance.red = 0; tolerance.red = 0;

Loading…
Cancel
Save