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

@smartface/image-processor

Package Overview
Dependencies
Maintainers
5
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smartface/image-processor - npm Package Compare versions

Comparing version

to
1.2.2

3

package.json
{
"name": "@smartface/image-processor",
"version": "1.2.1",
"version": "1.2.2",
"description": "iOS, Android image processor with different scales",

@@ -25,4 +25,5 @@ "main": "index.js",

"minimist": "^1.2.0",
"pngcrush": "^3.0.0",
"rmdir": "^1.2.0"
}
}

@@ -6,7 +6,7 @@ const fs = require('fs');

const PNGCRUSH_ARGS = [ '-rem', 'alla', '-nofilecheck', '-reduce', '-m', '7' ];
const PNGCRUSH_ARGS = ['pngcrush', '-rem', 'alla', '-nofilecheck', '-reduce', '-m', '7'];
function spawnPngCrush(args, options){
function spawnPngCrush(args, options) {
return new Promise((resolve, reject) => {
const pngcrush = spawn('pngcrush', args, options);
const pngcrush = spawn('npx', args, options);
let isErr = false;

@@ -18,3 +18,3 @@ pngcrush.on('error', (err) => {

pngcrush.on('close', () => {
if(!isErr) {
if (!isErr) {
resolve();

@@ -26,14 +26,14 @@ }

function minimizeImage(_sourceImagePath, destImagePath){
function minimizeImage(_sourceImagePath, destImagePath) {
let sourceImagePath = _sourceImagePath;
let isCopiedTemp = false;
if(sourceImagePath === destImagePath){
if (sourceImagePath === destImagePath) {
const tempFilePath = getTemporaryFilePath({ suffix: '.png' });
execSync(['cp', sourceImagePath, tempFilePath ].join(' '), {stdio: 'inherit'});
execSync(['cp', `"${sourceImagePath}"`, tempFilePath].join(' '), { stdio: 'inherit' });
isCopiedTemp = true;
sourceImagePath = tempFilePath;
}
return spawnPngCrush(PNGCRUSH_ARGS.concat([ sourceImagePath, destImagePath ]), { stdio: 'inherit' }).finally(()=>{
if(isCopiedTemp){
fs.unlink(sourceImagePath, ()=>{});
return spawnPngCrush(PNGCRUSH_ARGS.concat([sourceImagePath, destImagePath]), { stdio: 'inherit' }).finally(() => {
if (isCopiedTemp) {
fs.unlink(sourceImagePath, () => { });
}

@@ -43,3 +43,3 @@ });

function checkMinimizerAvailable(){
function checkMinimizerAvailable() {
return spawnPngCrush(['-version']);

@@ -51,2 +51,2 @@ }

checkMinimizerAvailable
}
};