title: Ionic2 + Dominant/Average Color
body: <p>Trying to get a dominant/average color of a profile image and use it as the background of the page in an Ionic2 / Angular2 app.</p>
  
  <p>Have tried Colorify.js, node-vibrant.js, Dominant-color.js and a few more...firstly, are there any tried and tested libraries that work (with some sample code if possible) ?</p>
  
  <p>Else, below is the snippet of my implementation of node-vibrant.js (node-vibrant) which is throwing an error</p>
  
  <pre><code>var vibrant = new Vibrant(JSON.stringify(this.user.attachments.profileImage));
  vibrant.getPalette(swatches =&gt; {
    for(var swatch in swatches) {
      if (swatches.hasOwnProperty(swatch) &amp;&amp; swatches[swatch]) {
        console.log("Swatches: " + swatch);
      }
    }
  });
  </code></pre>
  
  <p>The error/output I get is various depending on my limited coding skills...sometimes the swatches[swatch] is {}, sometimes swatches is printing just the text "raw", and sometimes I'm getting a cyclic code error.</p>
  
  <p>Any direction would be much appreciated.</p>