Browse Source

Cleaned up README

pull/134/head
James Cryer 7 years ago committed by GitHub
parent
commit
84a338a49f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 37
      README.md

37
README.md

@ -120,23 +120,7 @@ The resemble.compare API provides a convenience function that is used as follows
const compare = require('resemblejs').compare; const compare = require('resemblejs').compare;
function getDiff(){ function getDiff(){
const options = {};
const options = {
output: {
errorColor: {
red: 255,
green: 0,
blue: 255
},
errorType: 'movement',
transparency: 0.3,
largeImageThreshold: 1200,
useCrossOrigin: false,
outputDiff: true
},
scaleToSameSize: true,
ignore: ['nothing', 'less', 'antialiasing', 'colors', 'alpha'],
};
// 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
compare(image1, image2, options, function (err, data) { compare(image1, image2, options, function (err, data) {
@ -152,7 +136,6 @@ compare(image1, image2, options, function (err, data) {
getImageDataUrl: function(){} getImageDataUrl: function(){}
} }
*/ */
} }
}); });
} }
@ -160,20 +143,6 @@ compare(image1, image2, options, function (err, data) {
### Node.js ### Node.js
#### Installation
On Node, Resemble uses the `canvas` package instead of the native canvas support in the browser. To prevent browser users from being forced into installing Canvas, it's included as a peer dependency which means you have to install it alongside Resemble.
Canvas relies on some native image manipulation libraries to be install on the system. Please read the [Canvas installation instructions](https://www.npmjs.com/package/canvas) for OSX/Windows/Linux.
*Example commands for installation on OSX*
``` bash
npm install resemblejs
brew install pkg-config cairo libpng jpeg giflib
npm install canvas
```
#### Usage #### Usage
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:
@ -183,7 +152,6 @@ const compareImages = require('resemblejs/compareImages');
const fs = require("mz/fs"); const fs = require("mz/fs");
async function getDiff(){ async function getDiff(){
const options = { const options = {
output: { output: {
errorColor: { errorColor: {
@ -200,6 +168,7 @@ const options = {
scaleToSameSize: true, scaleToSameSize: true,
ignore: ['nothing', 'less', 'antialiasing', 'colors', 'alpha'], ignore: ['nothing', 'less', 'antialiasing', 'colors', 'alpha'],
}; };
// 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(
@ -209,11 +178,9 @@ const data = await compareImages(
); );
await fs.writeFile('./output.png', data.getBuffer()); await fs.writeFile('./output.png', data.getBuffer());
} }
getDiff(); getDiff();
``` ```
#### Tests #### Tests

Loading…
Cancel
Save