Soshot/bin/rasterize.js

27 lines
732 B
JavaScript
Raw Normal View History

var page = require('webpage').create(),
address, output;
2013-03-14 11:56:21 +01:00
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.settings.userAgent = 'SoShot Agent';
page.viewportSize = { width: 1280, height:1024};
2013-03-14 11:56:21 +01:00
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-26 15:23:02 +01:00
}, 300);
2013-03-14 11:56:21 +01:00
}
});
}