@ -40,7 +40,10 @@ var api = resemble(fileData).onComplete(function(data){
Use resemble to compare two images:
Use resemble to compare two images:
```javascript
```javascript
var diff = resemble(file).compareTo(file2).ignoreColors().onComplete(function(data){
var diff = resemble(file)
.compareTo(file2)
.ignoreColors()
.onComplete(function(data) {
console.log(data);
console.log(data);
/*
/*
{
{
@ -54,6 +57,7 @@ var diff = resemble(file).compareTo(file2).ignoreColors().onComplete(function(da
```
```
Scale second image to dimensions of the first one:
Scale second image to dimensions of the first one:
```javascript
```javascript
//diff.useOriginalSize();
//diff.useOriginalSize();
diff.scaleToSameSize();
diff.scaleToSameSize();
@ -68,7 +72,6 @@ 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
@ -78,12 +81,12 @@ resemble.outputSettings({
green: 0,
green: 0,
blue: 255
blue: 255
},
},
errorType: 'movement' ,
errorType: "movement" ,
transparency: 0.3,
transparency: 0.3,
largeImageThreshold: 1200,
largeImageThreshold: 1200,
useCrossOrigin: false,
useCrossOrigin: false,
outputDiff: true
outputDiff: true
})
});
// .repaint();
// .repaint();
```
```
@ -97,7 +100,7 @@ resemble.outputSettings({
right: 200,
right: 200,
bottom: 600
bottom: 600
}
}
})
});
// .repaint();
// .repaint();
```
```
@ -111,7 +114,7 @@ resemble.outputSettings({
right: 200,
right: 200,
bottom: 600
bottom: 600
}
}
})
});
// .repaint();
// .repaint();
```
```
@ -126,7 +129,7 @@ You can modify this behaviour by setting the `largeImageThreshold` option to a d
The resemble.compare API provides a convenience function that is used as follows:
The resemble.compare API provides a convenience function that is used as follows:
```js
```js
const compare = require('resemblejs' ).compare;
const compare = require("resemblejs" ).compare;
function getDiff() {
function getDiff() {
const options = {};
const options = {};
@ -134,7 +137,7 @@ function getDiff(){
// data is the same as usual with an additional getBuffer() function
// data is the same as usual with an additional getBuffer() function
compare(image1, image2, options, function(err, data) {
compare(image1, image2, options, function(err, data) {
if (err) {
if (err) {
console.log('An error!')
console.log("An error!");
} else {
} else {
console.log(data);
console.log(data);
/*
/*
@ -157,7 +160,7 @@ function getDiff(){
The API under Node is the same as on the `resemble.compare` but promise based:
The API under Node is the same as on the `resemble.compare` but promise based:
```js
```js
const compareImages = require('resemblejs/compareImages' );
const compareImages = require("resemblejs/compareImages" );
const fs = require("mz/fs");
const fs = require("mz/fs");
async function getDiff() {
async function getDiff() {
@ -168,25 +171,25 @@ async function getDiff(){
green: 0,
green: 0,
blue: 255
blue: 255
},
},
errorType: 'movement' ,
errorType: "movement" ,
transparency: 0.3,
transparency: 0.3,
largeImageThreshold: 1200,
largeImageThreshold: 1200,
useCrossOrigin: false,
useCrossOrigin: false,
outputDiff: true
outputDiff: true
},
},
scaleToSameSize: true,
scaleToSameSize: true,
ignore: ['nothing', 'less', 'antialiasing', 'colors', 'alpha'],
ignore: "antialiasing"
};
};
// The parameters can be Node Buffers
// The parameters can be Node Buffers
// data is the same as usual with an additional getBuffer() function
// data is the same as usual with an additional getBuffer() function
const data = await compareImages(
const data = await compareImages(
await fs.readFile('./demoassets/People.jpg' ),
await fs.readFile("./demoassets/People.jpg" ),
await fs.readFile('./demoassets/People2.jpg' ),
await fs.readFile("./demoassets/People2.jpg" ),
options
options
);
);
await fs.writeFile('./output.png' , data.getBuffer());
await fs.writeFile("./output.png" , data.getBuffer());
}
}
getDiff();
getDiff();
@ -202,7 +205,6 @@ npm run test
There are also some in-browser tests. To run these install and run a http-server such as [http-server ](https://github.com/indexzero/http-server ) from the root of the project. Then in the browser, navigate to `localhost:8080/chai-tests/test.html` , open up the developer console to see the results.
There are also some in-browser tests. To run these install and run a http-server such as [http-server ](https://github.com/indexzero/http-server ) from the root of the project. Then in the browser, navigate to `localhost:8080/chai-tests/test.html` , open up the developer console to see the results.
#### Dockerfile
#### Dockerfile
For convenience I've added a simple Dockerfile to run the NodeJS tests in an Ubuntu container
For convenience I've added a simple Dockerfile to run the NodeJS tests in an Ubuntu container
@ -212,8 +214,6 @@ docker build -t huddle/resemble .
docker run huddle/resemble
docker run huddle/resemble
```
```
---
--------------------------------------
Created by [James Cryer ](http://github.com/jamescryer ) and the Huddle development team.
Created by [James Cryer ](http://github.com/jamescryer ) and the Huddle development team.