Skip to content

Instantly share code, notes, and snippets.

@uggedal
Created February 6, 2012 20:05
Show Gist options
  • Save uggedal/1754479 to your computer and use it in GitHub Desktop.
Save uggedal/1754479 to your computer and use it in GitHub Desktop.
var page = require('webpage').create();
if (phantom.args.length !== 5) {
console.log('Usage: rasterize.js URL filename width height delay');
phantom.exit();
} else {
var address = phantom.args[0],
output = phantom.args[1],
width = parseInt(phantom.args[2]),
height = parseInt(phantom.args[3]),
delay = parseInt(phantom.args[4]);
page.viewportSize = { width: width, height: height };
page.clipRect = { width: width, height: height };
page.open(address, function (status) {
if (status !== 'success') {
console.log('Unable to load the address!');
} else {
page.evaluate(function() {
document.body.bgColor = 'white';
document.querySelector("#prompt-modal").style.display = "none";
});
window.setTimeout(function () {
page.render(output);
phantom.exit();
}, delay*1000);
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment