-4

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.

jimbo
  • 99
  • 1
  • 11
  • Write a script to parse the color variables in the main CSS file of a site ? – Amyth Jan 07 '13 at 09:59
  • Amyth this would be very underperforming, as the main css file can get quite big, and parsing it will be a pain in the ass. I didn't mention that I need a high-performance solution, as speed is viable and I'll be processing a lot of web sites at once... – jimbo Jan 07 '13 at 10:03

2 Answers2

1

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.

Community
  • 1
  • 1
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
0

Online Image Color Extractor:

Online Website Color Extractor:

powtac
  • 40,542
  • 28
  • 115
  • 170