views:

17

answers:

1

Are there any open source scripts that will allow you to enter a website url and it will generate a color palette based on your site? I would prefer something that ran on a typical LAMP stack. I've been able to find many websites that offer the functionality as a service but no downloadable scripts...

Update: I'm looking for the palette to contain the hex color values

A: 

Presumably easiest would be to render the page and count the pixels of different colors from a screenshot, because otherwise you can't tell which colors from the CSS file actually cover large areas. It's unlikely you could script this easily from command line but if you have a windowing environment, writing such a program wouldn't be too complicated. If you use QT, you can load the page into a QWebView, use QPixmap.grabWindow to get the pixels, convert it to QImage and then loop through the pixels counting them.

When converting the web page to an image, a big point to have in mind is that a user could send it to a malicious website to take advantage of a security problem in whatever rendering engine you are using, and even take over the server. Make sure to at least disable JavaScript and Flash, even though that will make some websites look different from normal. Otherwise it's far too easy to get the program stuck in an infinite loop even if nothing else.

jjrv
We thought of doing something like this, however, it seems that doing this would require a decent amount of server resources to render all the pages and images on a large scale. Is it possible to grab a css file without actually knowing the absolute path and then look for background-color or color?
Chad