Soshot/bin/rasterize.js

27 lines
679 B
JavaScript
Raw Normal View History

2013-03-14 11:56:21 +01:00
var page = new WebPage(),
address, output, size;
if (phantom.args.length < 2) {
2013-03-19 17:07:13 +01:00
//console.log('Usage: rasterize.js URL filename');
2013-03-14 11:56:21 +01:00
phantom.exit();
} else {
address = phantom.args[0];
output = phantom.args[1];
page.viewportSize = { width: 1280, height: 1024 };
page.open(address, function (status) {
if (status !== 'success') {
2013-03-19 17:07:13 +01:00
//console.log('Unable to load the address!');
page.close();
phantom.exit();
2013-03-14 11:56:21 +01:00
} else {
window.setTimeout(function () {
page.render(output);
2013-03-19 17:07:13 +01:00
page.close();
2013-03-14 11:56:21 +01:00
phantom.exit();
2013-03-19 17:07:13 +01:00
}, 200);
2013-03-14 11:56:21 +01:00
}
});
}