Skip to content

bevacqua/image-diff-2

 
 

Repository files navigation

image-diff Build status

Create image differential between two images

This was created as part of a visual regression project.

Example diff

Getting Started

Requirements

image-diff depends on ImageMagick.

Please install this before continuing.

Setup

Install the module with: npm install image-diff

var imageDiff = require('image-diff');
imageDiff({
  actualImage: 'checkerboard.png',
  expectedImage: 'white.png',
  diffImage: 'difference.png',
  threshold: 0
}, function (err, imagesAreSame,diffPercent) {
  // 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
  // diffPercent will have percentage of difference between two images
});

Documentation

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 - Path to output differential image
    • options.threshold Float - Float from 0 to 1 of how different the images can be. 0 means they must be identical. 1 means they can be completely different.

Contributing

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.

Attribution

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

License

Copyright (c) 2013 Uber

Licensed under the MIT license.

About

Create image differential between two images

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 98.9%
  • Shell 1.1%