Search code examples
javascriptnode.jshtmlnode-canvas

Find primary/dominant color of an image with canvas


I am new to node.js.

I´ve read the thread about Node.js Image Libraries and it seems that GM seems to be the most

advanced. I am trying to find out the most dominant color of an image using nodejs.

Then I have found this script color-thief , which is very interesting. It uses canvas to determine the color.

I found this node-canvas, which allows to create server side canvas.

Can I use color-thief and node-canvas together? Or am I missing something? Maybe someone has a better solution for nodejs.

Thanks!


Solution

  • Yep, there is a port for color-thief in node.js.

    Get the node.js friendly port here:

    https://npmjs.org/package/thief

    Install the package like this:

    $ npm install thief
    

    Include color-thief in your node script like this:

    var thief=require("thief");
    

    And use color-thief normally! ...