UNPKG

1.8 kBMarkdownView Raw
1# image-diff [![Build status](https://travis-ci.org/uber/image-diff.png?branch=master)](https://travis-ci.org/uber/image-diff)
2
3Create image differential between two images
4
5This was created as part of a [visual regression][] project.
6
7[visual regression]: http://www.youtube.com/watch?v=1wHr-O6gEfc
8
9## Getting Started
10### Requirements
11`image-diff` depends on [GraphicsMagick][] and [PhantomJS][].
12
13Please install these before continuing.
14
15[GraphicsMagick]: http://graphicsmagick.org/
16[PhantomJS]: http://phantomjs.org/
17
18### Setup
19Install the module with: `npm install image-diff`
20
21```javascript
22var imageDiff = require('image-diff');
23imageDiff({
24 actualImage: 'checkerboard.png',
25 expectedImage: 'white.png',
26 diffImage: 'difference.png',
27}, function (err, imagesAreSame) {
28 // error will be any errors that occurred
29 // imagesAreSame is a boolean whether the images were the same or not
30 // diffImage will have an image which highlights differences
31});
32```
33
34## Documentation
35`image-diff` exposes a function for you to callback with.
36
37### `diffImages(options, cb)`
38Create an differential image between multiple images
39
40- options `Object`
41 - options.actualImage `String` - Path to actual image file
42 - options.actualImage **must** exist
43 - options.expectedImage `String` - Path to expected image file
44 - If options.expectedImage does not exist, a transparent image with the same height/width will be created.
45 - options.diffImage `String` - Path to output differential image
46
47## Contributing
48In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint via [grunt](https://github.com/gruntjs/grunt) and test via `npm test`.
49
50## License
51Copyright (c) 2013 Uber
52
53Licensed under the MIT license.