Javascript function to extract main color(s) from images