How to get the dominant color or color palette from an image in JavaScript

laziel
1 min readOct 21, 2015

--

Try the Color Thief which created by Lokesh Dhakar. It extracts color palette using MMCQ(modified median cut quantization) algorithm.
http://lokeshdhakar.com/color-thief/

myImage = $('#myImage');
dominantColor = getDominantColor(myImage);
paletteArray = createPalette(myImage, 10); // 2nd argument sets # of colors in palette

Demo
http://lokeshdhakar.com/projects/color-thief/

License
MIT License

Requires
HTML5 Canvas available environment.

--

--