JS: Turn image into Vector art silhouette

I was recently asked to turn a bitmap image (.bmp) into a vector graphic and I wanted to do it using Javascript. NodeJS did the trick.  The first step was to use Homebrew to install potrace then use NPM to install Async.

NOTE! USE BMP, not JPG or PNG. Potrace prefers that format.

Step 1: Install Potrace through Homebrew

brew install Potrace

Step 2: Create Node App

// Create a new directory
mkdir ~/Desktop/my_new_app

// Change directory
cd ~/Desktop/my_new_app

// Create a new Node app
npm create

// Install async package
npm i async --save

Step 3: Build App

Paste this into your main file.

var sys = require('sys')
, exec  = require('child_process').exec
, async = require('async')
, util  = require('util')

// Place path of your images here
//!!!Notice that I am removing the file extension
var images = [
    "file1.bpm",
    "file2.jpg",
    "file3.jpg"
]

async.mapSeries(
    images,
    function(image, callback){
        //Manual 
        //http://potrace.sourceforge.net/potrace.1.html
        var params = {
            input:      image,
            output:     "-o " + image + ".eps",
            resolution: "--resolution 150",
            opaque:     "--opaque",
            alphamax:   "--alphamax 0.2",
            curve:      "--opttolerance 0.5",
            progress:   "--progress"
        }
        //Simple Example
        //exec("potrace " + composer + ".bmp -o " + image + ".eps " , callback);
        exec( 
            util.format( "potrace " + "%s %s %s %s %s %s %s", 
            params.input, 
            params.output,
            params.resolution,
            params.opaque,
            params.alphamax,
            params.curve,
            params.progress
        )
        , callback)
    },
    function(err, results) {
        if(err) console.error(err.message)
        else console.log(results)
    }
)