1 | # image-diff [![Build status](https://travis-ci.org/uber/image-diff.png?branch=master)](https://travis-ci.org/uber/image-diff)
|
2 |
|
3 | Create image differential between two images
|
4 |
|
5 | This 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][].
|
12 |
|
13 | Please install this before continuing.
|
14 |
|
15 | [GraphicsMagick]: http://graphicsmagick.org/
|
16 |
|
17 | ### Setup
|
18 | Install the module with: `npm install image-diff`
|
19 |
|
20 | ```javascript
|
21 | var imageDiff = require('image-diff');
|
22 | imageDiff({
|
23 | actualImage: 'checkerboard.png',
|
24 | expectedImage: 'white.png',
|
25 | diffImage: 'difference.png',
|
26 | }, function (err, imagesAreSame) {
|
27 | // error will be any errors that occurred
|
28 | // imagesAreSame is a boolean whether the images were the same or not
|
29 | // diffImage will have an image which highlights differences
|
30 | });
|
31 | ```
|
32 |
|
33 | ## Documentation
|
34 | `image-diff` exposes a function for you to callback with.
|
35 |
|
36 | ### `diffImages(options, cb)`
|
37 | Create an differential image between multiple images
|
38 |
|
39 | - options `Object`
|
40 | - options.actualImage `String` - Path to actual image file
|
41 | - options.actualImage **must** exist
|
42 | - options.expectedImage `String` - Path to expected image file
|
43 | - If options.expectedImage does not exist, a transparent image with the same height/width will be created.
|
44 | - options.diffImage `String` - Path to output differential image
|
45 |
|
46 | ## Contributing
|
47 | In 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`.
|
48 |
|
49 | ## License
|
50 | Copyright (c) 2013 Uber
|
51 |
|
52 | Licensed under the MIT license.
|