Grabs the dominant color or a representative color palette from an image. Uses javascript and canvas.
Pull request Compare This branch is 51 commits behind lokesh:master.
Latest commit 681cfe8 Apr 23, 2012 @lokesh lokesh Merge branch 'dev'
Permalink
Failed to load latest commit information.
css . Apr 23, 2012
img design improvements to demo page Nov 4, 2011
js js file had incorrect script name at top Apr 23, 2012
sass . Apr 23, 2012
.gitignore . Apr 23, 2012
README.markdown . Apr 23, 2012
index.html . Apr 23, 2012
index.js All of jfsiii awesome edits are now in place. Apr 22, 2012

README.markdown

Color Thief

A script for grabbing the dominant color or color palette from an image. Uses javascript and canvas.

See a Demo | Read more on my blog

Usage

Get Dominant Color

getDominantColor(sourceImage)
returns [num, num, num]

Uses the median cut algorithm provided by quantize.js to cluster similar colors and return the base color from the largest cluster.

Create Palette

createPalette(sourceImage, colorCount)
returns [ [num, num, num], [num, num, num], ... ]

Use the median cut algorithm provided by quantize.js to cluster similar colors.

License

by Lokesh Dhakar | lokeshdhakar.com | twitter.com/lokeshdhakar

Thanks to jfsiii for a large number of code improvements and others for submitting issues and fixes.

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.