fabianmoronzirfas
12/7/2016 - 11:42 AM

.gitignore

{
  "name": "thiefy",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "Fabian 'fabiantheblind' Morón Zirfas <fabian.moron.zirfas@gmail.com> (http://fabianmoronzirfas.me)",
  "license": "ISC",
  "dependencies": {
    "color-thief": "^2.2.2",
    "jquery": "^3.1.1"
  }
}
var ColorThief = require('color-thief');
var colorThief = new ColorThief();
var sourceImage = './tower.jpg';
var res = colorThief.getPalette(sourceImage, 8);
console.log(res);
<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Page Title</title>
    <meta name="description" content="something">
    <meta name="author" content="me">
  </head>
  <body>
    <img src="./tower.jpg" alt="" id="srcImage">
    <script type="text/javascript" src="./node_modules/jquery/dist/jquery.js"></script>
    <script type="text/javascript" src="./node_modules/color-thief/js/color-thief.js"></script>
    <script type="text/javascript">
    $(window).ready(function(){

      var myImage = $('#srcImage');
      var colorThief = new ColorThief();
      var palette = colorThief.getPalette(myImage[0], 8);
      console.log(palette);
      // dominantColor = getDominantColor(myImage[0]);
      // paletteArray = createPalette(myImage, 10); // 2nd argument sets # of colors in palette
    });
    </script>
  </body>
</html>
*.jpg
# MAC OSX
.DS_Store
# WIN
Thumbs.db
# nodejs and web dev
node_modules