确定网站主要颜色[关闭]

Can someone tell me the best way to determine the 5-6 most used colors in a website ( not an image ) using PHP and/or javascript. I've searched through the net, but all I could find was some third-party solutions ( which don't suit my needs ), and such that extract the color from an image.

I'll be grateful if you can help in any way.

As a general strategy, get a screenshot of the website and store it in a lossless image format (e.g. PNG but not JPEG). Then loop over all the pixels and get their colour. Store the results in an associated array (( 'colour code' => 'count of pixels with that colour' )). Loop over that array and find the highest counts. Those are your colours.