Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

diverged

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

diverged - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

fixtures/lhw/settings compare.acorn

24

demo/browser.js

@@ -5,7 +5,8 @@ 'use strict';

img1.onload = isReady;
// img1.src = "http://127.0.0.1:3000/fixtures/lpc/margin_ref.png";
// img1.src = "http://127.0.0.1:3000/fixtures/lhw/settings_ref.png";
img1.src = "http://127.0.0.1:3000/fixtures/lpc/margin_ref.png";
// img1.src = "http://127.0.0.1:3000/fixtures/lpc/chwu_ref.png";
// img1.src = "http://127.0.0.1:3000/fixtures/small/50_remove_ref.png";
// img1.src = "http://127.0.0.1:3000/fixtures/pricing/600_2_test.png";
img1.src = "http://127.0.0.1:3000/fixtures/pricing/320_test.png";
// img1.src = "http://127.0.0.1:3000/fixtures/pricing/320_ref.png";
// img1.src = "http://127.0.0.1:3000/fixtures/pricing/1024_ref.png";

@@ -15,7 +16,8 @@

img2.onload = isReady;
// img2.src = "http://127.0.0.1:3000/fixtures/lpc/margin_test.png";
// img2.src = "http://127.0.0.1:3000/fixtures/lhw/settings_test.png";
img2.src = "http://127.0.0.1:3000/fixtures/lpc/margin_test.png";
// img2.src = "http://127.0.0.1:3000/fixtures/lpc/chwu_test.png";
// img2.src = "http://127.0.0.1:3000/fixtures/small/50_remove_test.png";
// img2.src = "http://127.0.0.1:3000/fixtures/pricing/600_2_ref.png";
img2.src = "http://127.0.0.1:3000/fixtures/pricing/320_ref.png";
// img2.src = "http://127.0.0.1:3000/fixtures/pricing/320_test.png";
// img2.src = "http://127.0.0.1:3000/fixtures/pricing/1024_test.png";

@@ -64,4 +66,4 @@

// meyersImgData.data = divergedImgData;
console.time("imgDataToMeyersImgData");
// lcsImgData.data = divergedImgData;
console.time("imgDataTolcsImgData");
let clampedImgData = getEmptyImgData(h, w)

@@ -71,6 +73,6 @@ for (var i = divergedImgData.length - 1; i >= 0; i--) {

}
var meyersDiffResult = imageToCanvasContext(null, w, h);
meyersDiffResult.putImageData(clampedImgData, 0, 0);
console.timeEnd("imgDataToMeyersImgData");
// console.log('meyersDiffResult>>>', clampedImgData);
var lcsDiffResult = imageToCanvasContext(null, w, h);
lcsDiffResult.putImageData(clampedImgData, 0, 0);
console.timeEnd("imgDataTolcsImgData");
// console.log('lcsDiffResult>>>', clampedImgData);

@@ -83,3 +85,3 @@ console.timeEnd("total_time");

document.getElementById('pixelmatch2').src = pixelmatchResult.canvas.toDataURL("image/png");
document.getElementById('meyersResult').src = meyersDiffResult.canvas.toDataURL("image/png");
document.getElementById('lcsResult').src = lcsDiffResult.canvas.toDataURL("image/png");

@@ -86,0 +88,0 @@ }

'use strict';
const ts = new Date().getTime();
const OUTPUT_PATH = `../results/${ts}.png`
// const REF_PATH = './fixtures/pricing/1024_ref.png';
// const TEST_PATH = './fixtures/pricing/1024_test.png';
const REF_PATH = '../fixtures/pricing/320_ref.png';
const TEST_PATH = '../fixtures/pricing/320_test.png';
const OUTPUT_PATH = `../results/${new Date().getTime()}.png`
const PNG = require('pngjs').PNG;
const fs = require('fs');
const match = require('pixelmatch');
const diverged = require('../src/diverged');
var threshold = undefined,
includeAA = false;
var ref_img = fs.createReadStream(REF_PATH).pipe(new PNG()).on('parsed', runDiverged);
var test_img = fs.createReadStream(TEST_PATH).pipe(new PNG()).on('parsed', runDiverged);
function runDiverged() {
if (!ref_img.data || !test_img.data) return;
var diff = new PNG({width: ref_img.width, height: ref_img.height});
var divergedDiff = diverged(ref_img.data, test_img.data, ref_img.height, ref_img.width);
diff.data = divergedDiff;
diff.pack().pipe(fs.createWriteStream(OUTPUT_PATH));
}
function runDiff() {
if (!ref_img.data || !test_img.data) return;
var diff = new PNG({width: ref_img.width, height: ref_img.height});
console.time('match');
var diffs = match(ref_img.data, test_img.data, diff.data, diff.width, diff.height, {
threshold: threshold,
includeAA: includeAA
});
console.timeEnd('match');
diff.pack().pipe(fs.createWriteStream(OUTPUT_PATH));
console.log('diverged pixels: ' + diffs);
console.log('error: ' + (Math.round(100 * 100 * diffs / (diff.width * diff.height)) / 100) + '%');
}
const diverged = require('../src/diverged-node')
const result = diverged(REF_PATH, TEST_PATH, OUTPUT_PATH);
{
"name": "diverged",
"version": "0.1.0",
"version": "0.1.1",
"description": "Compare UI screenshots with document flow detection.",

@@ -16,4 +16,5 @@ "main": "src/diverged.js",

"pixelmatch": "^4.0.2",
"pngjs": "^3.3.3",
"super-simple-web-server": "^1.0.0"
}
}

@@ -21,3 +21,3 @@ 'use strict';

* @param {Uint8ClampedArray} [reference] baseline image
* @param {Uint8ClampedArray} [test] baseline image
* @param {Uint8ClampedArray} [test] test image
*

@@ -24,0 +24,0 @@ * @returns {Uint8ClampedArray} diff image

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc