Last active
August 29, 2015 14:01
-
-
Save vahan-hartooni/b0954ae67767ef830eec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This phantomJS script takes these arguments: | |
// [url] [pageWidth] [pageHeight] [output filename] | |
// System module so we can access the arguments | |
var system = require('system'), | |
// Initialize webpage | |
page = require('webpage').create(), | |
// Set our arguments | |
url = system.args[1] ? system.args[1] : 'http://www.html5zombo.com', | |
pageWidth = system.args[2] ? parseInt(system.args[2], 10) : 960, | |
pageHeight = system.args[3] ? parseInt(system.args[3], 10) : 720, | |
output = system.args[4] ? system.args[4] : 'screenshot.png'; | |
// Set the resolution | |
page.viewportSize = { width: pageWidth, height: pageHeight }; | |
page.open(url, function(status) { | |
if (status !== 'success') { | |
console.log('Unable to access network'); | |
phantom.exit(1); | |
} else { | |
// Where the screenshot is actually created | |
page.render(output); | |
phantom.exit(); | |
} | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment