Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Create image differential between two images
JavaScript Shell
branch: master

image-diff Build status

Create image differential between two images

This was created as part of a visual regression project.

Example diff

Getting Started


image-diff depends on ImageMagick.

Please install this before continuing.


Install the module with: npm install image-diff

var imageDiff = require('image-diff');
  actualImage: 'checkerboard.png',
  expectedImage: 'white.png',
  diffImage: 'difference.png',
}, function (err, imagesAreSame) {
  // error will be any errors that occurred
  // imagesAreSame is a boolean whether the images were the same or not
  // diffImage will have an image which highlights differences


image-diff exposes a function for you to callback with.

diffImages(options, cb)

Create an differential image between multiple images

  • options Object
    • options.actualImage String - Path to actual image file
      • options.actualImage must exist
    • options.expectedImage String - Path to expected image file
      • If options.expectedImage does not exist, a transparent image with the same height/width will be created.
    • options.diffImage String - Optional path to output differential image
    • options.shadow Boolean - Optional flag to indicate if we should draw a shadow of the unchanged parts of the images
      • For example, if an image is + and we diff with -, then the image will have | be red but also contain a faded -
      • By default, this options is false meaning a shadow will not be drawn


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 and test via npm test.


The font used for the example image is Arial 30pt bold and Courier New 38pt.


Copyright (c) 2013 Uber

Licensed under the MIT license.

Something went wrong with that request. Please try again.