var file_png = system.args[2] || 'indexdata.png';
var timeout = system.args[5] ? system.args[5] : 0.2;
-if (system.args.length === 1) {
+function usage (message) {
+ if (message) {
+ console.log(message + "\n");
+ }
console.log('Usage: screenshot.js <some URL> <file.png>');
phantom.exit();
}
+if (system.args.length === 1) {
+ usage();
+}
+
+if (!file_png.match(/\.png$/)) {
+ usage("File name has no .png extension: '" + file_png + "'");
+}
+
+
// page.zoomFactor = 1.0;
page.viewportSize = {
width: system.args[3] ? system.args[3] : 1200,
phantom.exit();
}, timeout * 1000);
});
+
+// EOF