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

pixel-compare

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pixel-compare - npm Package Compare versions

Comparing version

to
1.0.3

35

index.js

@@ -14,29 +14,6 @@ "use strict";

if (!basedImagePath) {
console.error("Need to provide basedImage");
process.exit(1);
}
if (!testImagePath) {
console.error("Need to provide testImage");
process.exit(1);
}
let imageType;
if (outputImagePath) {
const outputImagePathLength = outputImagePath.length;
const isJpeg = outputImagePath.indexOf(".jpeg") === (outputImagePathLength - 5);
const isJpg = outputImagePath.indexOf(".jpg") === (outputImagePathLength - 4);
const isPng = outputImagePath.indexOf(".png") === (outputImagePathLength - 4);
if (!isJpeg && !isJpg && !isPng) {
console.error("Output image type is not supported");
process.exit(1);
}
imageType = isJpeg ? "jpeg" : (isPng ? "png" : "jpg");
}
const basedImagePromise = new Promise((resolve, reject) => {
getPixels(basedImagePath, function(err, pixels){
if (err) {
reject("Reading based image failed" + err);
reject(`Reading based image failed. ${err}`);
}

@@ -50,3 +27,3 @@ resolve(pixels);

if (err) {
reject("Reading test image failed" + err);
reject(`Reading test image failed. ${err}`);
}

@@ -128,2 +105,10 @@ resolve(pixels);

if (outputImagePath) {
const outputImagePathLength = outputImagePath.length;
const isJpeg = outputImagePath.indexOf(".jpeg") === (outputImagePathLength - 5);
const isJpg = outputImagePath.indexOf(".jpg") === (outputImagePathLength - 4);
const isPng = outputImagePath.indexOf(".png") === (outputImagePathLength - 4);
if (!isJpeg && !isJpg && !isPng) {
throw Error("Output image type is not supported");
}
const imageType = isJpeg ? "jpeg" : (isPng ? "png" : "jpg");
const resultNdarray = ndarray(

@@ -130,0 +115,0 @@ Uint8Array.from(resultArray),

{
"name": "pixel-compare",
"version": "1.0.2",
"version": "1.0.3",
"description": "compare pixel of image for PNG, JPEG or DataURL.",

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

@@ -42,6 +42,6 @@ # pixel-compare

* `baseColor`: is optional, array of 4 for base color is test color is all 0
* `baseColor`: is optional, array of 4 for base color when test color is all 0
* `testColor`: is optional, array of 4 for test color is base color is all 0
* `testColor`: is optional, array of 4 for test color when base color is all 0
##### `return` a promise with a boolean to indicate if two images are the same.

Sorry, the diff of this file is not supported yet