New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

pam-diff

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pam-diff - npm Package Compare versions

Comparing version 0.8.2 to 0.8.4

79

index.js

@@ -57,2 +57,3 @@ // jshint esversion: 6, globalstrict: true, strict: true, bitwise: false

delete this._regionsLength;
delete this._minDiff;
}

@@ -65,2 +66,3 @@ this._diffs = 0;

this._regions = [];
this._minDiff = 255;
for (const region of regions) {

@@ -71,2 +73,6 @@ if (!region.hasOwnProperty('name') || !region.hasOwnProperty('polygon')) {

const polygonPoints = new PP(region.polygon);
const pointsLength = polygonPoints.pointsLength;
const difference = this._validateNumber(parseInt(region.difference), this._difference, 1, 255);
const percent = this._validateNumber(parseInt(region.percent), this._percent, 1, 100);
this._minDiff = Math.min(this._minDiff, difference);
this._regions.push(

@@ -76,5 +82,5 @@ {

polygon: polygonPoints,
pointsLength: polygonPoints.pointsLength,
difference: this._validateNumber(parseInt(region.difference), this._difference, 1, 255),
percent: this._validateNumber(parseInt(region.percent), this._percent, 1, 100),
pointsLength: pointsLength,
difference: difference,
percent: percent,
diffs: 0

@@ -141,5 +147,5 @@ }

const diff = this._oldPix[i] !== this._newPix[i];
if (this._regions) {
if (this._regions && diff === true) {
for (let j = 0; j < this._regionsLength; j++) {
if (diff === true && this._regions[j].polygon.containsPoint(x, y) === true) {
if (this._regions[j].polygon.containsPoint(x, y) === true) {
this._regions[j].diffs++;

@@ -181,13 +187,15 @@ }

for (let x = 0; x < this._width; x++, i++) {
const diff = Math.abs(this._oldPix[i] - this._newPix[i]);
if (this._regions) {
for (let j = 0; j < this._regionsLength; j++) {
if (diff >= this._regions[j].difference && this._regions[j].polygon.containsPoint(x, y) === true) {
this._regions[j].diffs++;
if (this._oldPix[i] !== this._newPix[i]) {
const diff = Math.abs(this._oldPix[i] - this._newPix[i]);
if (this._regions && diff >= this._minDiff) {
for (let j = 0; j < this._regionsLength; j++) {
if (diff >= this._regions[j].difference && this._regions[j].polygon.containsPoint(x, y) === true) {
this._regions[j].diffs++;
}
}
} else {
if (diff >= this._difference) {
this._diffs++;
}
}
} else {
if (diff >= this._difference) {
this._diffs++;
}
}

@@ -222,13 +230,15 @@ }

for (let x = 0; x < this._width; x++, i += 3) {
const diff = Math.abs(this._grayscale(this._oldPix[i], this._oldPix[i + 1], this._oldPix[i + 2]) - this._grayscale(this._newPix[i], this._newPix[i + 1], this._newPix[i + 2]));
if (this._regions) {
for (let j = 0; j < this._regionsLength; j++) {
if (diff >= this._regions[j].difference && this._regions[j].polygon.containsPoint(x, y) === true) {
this._regions[j].diffs++;
if (this._oldPix[i] !== this._newPix[i] || this._oldPix[i + 1] !== this._newPix[i + 1] || this._oldPix[i + 2] !== this._newPix[i + 2]) {
const diff = Math.abs(this._grayscale(this._oldPix[i], this._oldPix[i + 1], this._oldPix[i + 2]) - this._grayscale(this._newPix[i], this._newPix[i + 1], this._newPix[i + 2]));
if (this._regions && diff >= this._minDiff) {
for (let j = 0; j < this._regionsLength; j++) {
if (diff >= this._regions[j].difference && this._regions[j].polygon.containsPoint(x, y) === true) {
this._regions[j].diffs++;
}
}
} else {
if (diff >= this._difference) {
this._diffs++;
}
}
} else {
if (diff >= this._difference) {
this._diffs++;
}
}

@@ -263,13 +273,15 @@ }

for (let x = 0; x < this._width; x++, i += 4) {
const diff = Math.abs(this._grayscale(this._oldPix[i], this._oldPix[i + 1], this._oldPix[i + 2]) - this._grayscale(this._newPix[i], this._newPix[i + 1], this._newPix[i + 2]));
if (this._regions) {
for (let j = 0; j < this._regionsLength; j++) {
if (diff >= this._regions[j].difference && this._regions[j].polygon.containsPoint(x, y) === true) {
this._regions[j].diffs++;
if (this._oldPix[i] !== this._newPix[i] || this._oldPix[i + 1] !== this._newPix[i + 1] || this._oldPix[i + 2] !== this._newPix[i + 2]) {
const diff = Math.abs(this._grayscale(this._oldPix[i], this._oldPix[i + 1], this._oldPix[i + 2]) - this._grayscale(this._newPix[i], this._newPix[i + 1], this._newPix[i + 2]));
if (this._regions && diff >= this._minDiff) {
for (let j = 0; j < this._regionsLength; j++) {
if (diff >= this._regions[j].difference && this._regions[j].polygon.containsPoint(x, y) === true) {
this._regions[j].diffs++;
}
}
} else {
if (diff >= this._difference) {
this._diffs++;
}
}
} else {
if (diff >= this._difference) {
this._diffs++;
}
}

@@ -340,3 +352,2 @@ }

module.exports = PamDiff;
//todo get bounding box of all regions combined to exclude some pixels before checking if they exist inside specific regions
//todo add option for break on first region so that pixel is not measured in multiple overlapping regions
//todo get bounding box of all regions combined to exclude some pixels before checking if they exist inside specific regions
{
"name": "pam-diff",
"version": "0.8.2",
"version": "0.8.4",
"description": "Measure differences between pixel arrays extracted from pam images",

@@ -5,0 +5,0 @@ "main": "index.js",

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