Would it be nice if we can see the preview of a web page before we actually visit it? Apparently browser add-ons and WordPress plugin that implement this feature do exist. Some of them rely on the server-side solution to create the preview, others do that right at the client-side. The server-side solution might be faster because it can cache some of popular web sites, however it might trouble some people who care a lot for privacy.
The example today demonstrates a nice usage of QtWebKit to generate the web thumbnail. Basically it grabs the content of the web page, renders to an image, scales the image to the intended size, and then saves the result. Could not be easier, could it?
svn checkout svn://labs.trolltech.com/svn/graphics/dojo/websnap cd websnap && qmake && make
After it is built, an easy example would be:
./websnap www.trolltech.com trolltech.png
And then check out the output file!
Exercise for the reader: this tool renders everything and thus could be really slow for a big page (think of Digg). For a previewer, typically you just want some part of the beginning of the a very long page. Thus, the challenge is to modify the program to actually do a progressive rendering and stop if necessary.
Комментариев нет:
Отправить комментарий