get dominant color of an image node js
<p>I'm trying to get the dominant color of an image I have on my computer.
I installed <code>imagemagick</code> and <code>dominant-color</code> before using this code.
I get the result of <code>undefined</code> and <code>000000</code>.</p>

<p>Why is that happening? What did I do wrong?</p>

<pre><code>var AWS = require('aws-sdk'),
fs = require('fs');
var express = require("express");
var app = express();

const resizeImg = require('resize-img');
var color = require('dominant-color'),
    imgPath = './Users/ADIBAR/Desktop/cloud/beach_life-normal.jpg';

color(imgPath,function(err,color){
    console.log(color);
})

color(imgPath,{format:'rgb'},function(err,color){
    console.log(color);
})

// For dev purposes only
AWS.config.update({ accessKeyId: '', secretAccessKey: '' });

var fileStream = fs.createReadStream('beach_life-normal.jpg');
fileStream.on('error', function (err) {
  if (err) { throw err; }
});  

fileStream.on('open', function () {
  var s3 = new AWS.S3();




resizeImg(fs.readFileSync('beach_life-normal.jpg'), {width: 128, height:128}).then(buf =&gt; {
    fs.writeFileSync('beach_life-normal-new.jpg', buf);
    //upload//
    s3.putObject({
      Bucket: 'adinoauploadefile',
      Key: 'beach_life-normal-new.jpg',
      Body: 'beach_life-normal-new.jpg'
    }, function (err) {
     if (err) { throw err; }
    });
  });  
});
</code></pre>