यहाँ जो एक पूरे वेब पेज के एक screengrab बनाता है एक नमूना क्यूटी 4 कमांड लाइन अनुप्रयोग है - थंबनेल पीढ़ी के लिए अनुकूल करने के लिए आसान ....
#include <QtGui/QApplication>
#include <QtCore/QCoreApplication>
#include <QtGui>
#include <QtWebKit>
#include <QWebPage>
#include <QTextStream>
#include <QSize>
QWebView *view;
QString outfile;
void QWebView::loadFinished(bool ok)
{
QTextStream out(stdout);
if (!ok) {
out << "Page loading failed\n";
return;
}
view->page()->setViewportSize(view->page()->currentFrame()->contentsSize());
QImage *img = new QImage(view->page()->viewportSize(), QImage::Format_ARGB32);
QPainter *paint = new QPainter(img);
view->page()->currentFrame()->render(paint);
paint->end();
if(!img->save(outfile, "png"))
out << "Save failure\n";
QApplication::quit();
return;
}
int main(int argc, char *argv[])
{
QTextStream out(stdout);
if(argc < 3) {
out << "USAGE: " << argv[0] << " <url> <outfile>\n";
return -1;
}
outfile = argv[2];
QApplication app(argc, argv);
view = new QWebView();
view->load(QUrl(argv[1]));
return app.exec();
}
आप एक सर्वर xvfb भी प्रयोग पर इस चला सकते हैं। मूल के लिए this blog post और एक पायथन विकल्प के लिए एक लिंक देखें।
स्रोत
2009-08-24 07:16:27