GithubHelp home page GithubHelp logo

james1x0 / color-thief Goto Github PK

View Code? Open in Web Editor NEW

This project forked from null2/color-thief

1.0 1.0 1.0 1.21 MB

Grabs the dominant color or a representative color palette from an image. Uses javascript and canvas.

CSS 23.32% JavaScript 61.75% HTML 6.28% Sass 8.64%

color-thief's Introduction

Color Thief

A script for grabbing the color palette from an image. Uses Javascript and the canvas tag to make it happen.

See a Demo | Read more on my blog

How to use

Get the dominant color from an image

var colorThief = new ColorThief();
colorThief.getColor(sourceImage);
getColor(sourceImage[, quality])
returns {r: num, g: num, b: num}

Build a color palette from an image

In this example, we build an 8 color palette.

var colorThief = new ColorThief();
colorThief.getPalette(sourceImage, 8);
getPalette(sourceImage[, colorCount, quality])
returns [ [num, num, num], [num, num, num], ... ]

Node.js

Install the module via npm

npm install color-thief

And use it:

var ColorThief = require('color-thief');

Node Tests

Run the node tests via npm test

Credits and license

Author

by Lokesh Dhakar
lokeshdhakar.com
twitter.com/lokesh

Thanks

  • Nick Rabinowitz - For creating quantize.js.
  • John Schulz - For clean up and optimization. @JFSIII
  • Nathan Spady - For adding drag and drop support to the demo page.

License

Licensed under the Creative Commons Attribution 2.5 License

  • Free for use in both personal and commercial projects.
  • Attribution requires leaving author name, author homepage link, and the license info intact.

color-thief's People

Contributors

argl avatar esatterwhite avatar james1x0 avatar jo avatar jonnor avatar kherock avatar lokesh avatar lukyvj avatar michaelhart avatar nobodypb avatar nspady avatar petersonbrock avatar piscis avatar ryanackley avatar seantcanavan avatar sgraham785 avatar throrin19 avatar

Watchers

 avatar

Forkers

pushbots

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.