Skip to content

Instantly share code, notes, and snippets.

@skateman
Created May 7, 2015 11:49
Show Gist options
  • Save skateman/8c33b186d01c3e1001fd to your computer and use it in GitHub Desktop.
Save skateman/8c33b186d01c3e1001fd to your computer and use it in GitHub Desktop.
PhantomJS Screen Capture
/*
* Usage: phantomjs capture.js [width] [height] [url] [output]
*/
var system = require('system');
var args = system.args;
if (args.length === 5) {
var width = args[1];
var height = args[2];
var url = args[3];
var output = args[4];
var page = require('webpage').create();
page.viewportSize = { width: width, height: height };
page.open(url, function() {
page.render(output);
phantom.exit();
});
} else {
console.log("Invalid argument!");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment