1 var page = require('webpage').create(),
2 system = require('system');
4 var url = system.args[1] || 'http://www.indexdata.com/';
5 var file_png = system.args[2] || 'indexdata.png';
6 var timeout = system.args[5] ? system.args[5] : 0.2;
8 function usage(message) {
10 console.log(message + "\n");
12 console.log('Usage: screenshot.js <some URL> <file.png> <width px> <height px> <timeout sec>');
16 if (system.args.length === 1) {
20 if (!file_png.match(/\.png$/)) {
21 usage("File name has no .png extension: '" + file_png + "'");
25 // page.zoomFactor = 1.0;
27 width: system.args[3] ? system.args[3] : 1200,
28 height: system.args[4] ? system.args[4] : 1000
32 width: page.viewportSize.width,
33 height: page.viewportSize.height
36 page.open(url, function () {
38 setTimeout(function () {
39 var ret = page.render(file_png);