JavaScript像素級圖像比較庫:pixelmatch

fkd27 9年前發布 | 10K 次閱讀 JavaScript開發 pixelmatch

最小,最簡單,和最快的JavaScript 像素級圖像比較庫,主要設計用于回歸測試的對比截圖。

API

pixelmatch(img1, img2, output, width, height[, threshold, antialiasing])

  • img1,img2— Image data of the images to compare (BufferorUint8Array).
  • output— Image data to write the diff to.
  • width,height— Width and height of the images. Note that all three images need to have the same dimensions.
  • threshold— Matching threshold, ranges from0to1. Smaller values make the comparison more sensitive.0.005by default.
  • antialiasing— Radius of antialiasing to ignore in pixels.1by default.

Compares two images, writes the output diff and returns the number of mismatched pixels.

Command line

Pixelmatch comes with a binary that works with PNG images:

pixelmatch image1.png image2.png output.png 0.005 1

Install

Install with NPM:

npm install pixelmatch

To build a browser-compatible version, clone the repository locally, then run:

npm install -g browserify
browserify -s pixelmatch index.js > pixelmatch.js



項目主頁:http://www.baiduhome.net/lib/view/home/1445081018435

 本文由用戶 fkd27 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!