Skip to content

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

Notifications You must be signed in to change notification settings

fengyiyi/color-thief

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

#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.

About

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

Resources

Stars

Watchers

Forks

Packages

No packages published