+26
-9
@@ -7,23 +7,39 @@ var spawn = require('child_process').spawn; | ||
| var convert = spawn('convert',[path,'-colors','16','-depth','8','-format', '%c', 'histogram:info:-']), | ||
| out = "", | ||
| err = ""; | ||
| out = "", | ||
| err = ""; | ||
| convert.stdout.on('data',function(data){ | ||
| out += data.toString(); | ||
| }); | ||
| }); | ||
| convert.stdout.on('data',function(data){ | ||
| err += data.toString(); | ||
| }); | ||
| }); | ||
| convert.on('exit',function(code){ | ||
| err = code?(err?err:code):false; | ||
| // a big note. exit may be fired before or after close of stdout (0.8.20) | ||
| // to respond properly in any lib using spawn you really need to wait for both. | ||
| var exit,closed | ||
| , done = function(){ | ||
| if(exit === undefined) process.exit(9); | ||
| err = exit?(err?err:exit):false; | ||
| var colors; | ||
| if(!err){ | ||
| colors = parseImagickColors(out); | ||
| } | ||
| if(!colors.length){ | ||
| console.log('no colors from parse:',out); | ||
| } | ||
| } | ||
| cb(exit?(err?err:exit):false,colors); | ||
| }; | ||
| cb(code?(err?err:code):false,colors); | ||
| }); | ||
| convert.on('exit',function(code){ | ||
| exit = code; | ||
| if(closed) done(); | ||
| }); | ||
| convert.stdout.on('close',function(){ | ||
| closed = true; | ||
| if(exit !== undefined) done(); | ||
| }); | ||
| convert.stdin.end(); | ||
@@ -33,2 +49,3 @@ | ||
| // | ||
@@ -35,0 +52,0 @@ //a valid color object response is [] |
+1
-1
| { | ||
| "name": "colormatch" | ||
| , "description": "A module for extracting colors from images and for generating lookup ranges that accept rgb and outputs ranges of rgb values for db lookups. Right now it uses ImageMagik in a child process to reduce the colorspace and return the top colors of an image. Alterntives with node-canvas or an all js jpeg decoder could be used. The latterwith the same js color quantization algorthims that would be needed to reduce the colorspace of the former." | ||
| , "version": "0.0.2" | ||
| , "version": "0.0.3" | ||
| , "author": "Ryan Day <soldair@gmail.com>" | ||
@@ -6,0 +6,0 @@ , "keywords": ["image", "indexing", "color", "search"] |
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
9938
5.22%171
9.62%