js-imagediff

JavaScript / Canvas based image diff utility with Jasmine matchers for testing canvas.

  • 所有者: HumbleSoftware/js-imagediff
  • 平台:
  • 許可證: MIT License
  • 分類:
  • 主題:
  • 喜歡:
    0
      比較:

Github星跟蹤圖

js-imagediff

JavaScript / Canvas based imagediff utility.

API

  • createCanvas() create a new Canvas element.
  • createImageData(width, height) create a new ImageData object.
  • isImage(object) tests for Image object.
  • isCanvas(object) tests for Canvas object.
  • isContext(object) tests for CanvasRenderingContext2D object.
  • isImageData(object) tests for ImageData object.
  • isImageType(object) tests for any of the above.
  • toImageData(object) converts image type object to a new ImageData object.
  • equal(a, b, tolerance) tests image type objects for equality; accepts tolerance in pixels.
  • diff(a, b, options) performs an image diff on a and b, returning a - b.
    • options.align set to 'top' to top-align the images when diffing different sizes.
  • noConflict() removes imagediff from the global space for compatibility, returning imagediff.
  • imageDataToPNG(imageData, outputFile, [callback]) (node only) renders the imageData to png in outputFile with optional callback.

NodeJS

js-imagediff is available through the npm. It uses node-canvas which requires lib cairo to be installed.
Install js-imagediff with npm install -g imagediff.

Command Line

  • imagediff [-e, equal] [-t, tolerance VALUE] FILE_A FILE_B tests equality of two image files with an optional tolerance, printing 'true' or 'false'.
  • imagediff [-d, diff] FILE_A FILE_B OUTPUT_FILE renders an imagediff between two files, saving as the output file.

Cannot find module 'canvas'

Canvas has been moved to an optional dependency for better browser and browserify support. If you see a message that the module cannot be found, please check npm install first, incase there was indeed an issue installing it. This relates to https://github.com/HumbleSoftware/js-imagediff/issues/22. Please let me know if you have any issues on account of this, or know of a better work around.

Unit Testing Canvas

JS ImageDiff opens up the easy testing of Canvas and other image-like objects in JavaScript. js-imagediff supplies two Jasmine matchers to make this easier.

  • toImageDiffEqual(expected, tolerance) expect a result to equal another image type.
  • toBeImageData() expect a result to be ImageData.

On failed tests, toImageDiffEqual() will display the expected image, the actual image and the imagediff of the two letting you easily spot mistakes.

To use matchers:

  beforeEach(function () {
    this.addMatchers(imagediff.jasmine);
  });

Demo

Users

If you are using js-imagediff pelase drop us a line and let us know what you are doing with it.

Changelog

Author

Carl Sutherland carl@humblesoftware.com
http://www.humblesoftware.com

主要指標

概覽
名稱與所有者HumbleSoftware/js-imagediff
主編程語言JavaScript
編程語言Makefile (語言數: 2)
平台
許可證MIT License
所有者活动
創建於2011-10-26 21:08:23
推送於2022-12-07 11:55:15
最后一次提交2020-05-19 20:14:20
發布數4
最新版本名稱v1.0.8 (發布於 2015-01-28 16:12:41)
第一版名稱v1.0.4 (發布於 2013-08-15 19:29:44)
用户参与
星數790
關注者數23
派生數99
提交數197
已啟用問題?
問題數38
打開的問題數19
拉請求數21
打開的拉請求數15
關閉的拉請求數10
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?