Created
August 24, 2015 10:48
-
-
Save kopiro/37702a8b0b40a716e6e7 to your computer and use it in GitHub Desktop.
PhantomJS Renderer
This file contains hidden or 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
#!/usr/bin/env phantomjs | |
var args = require('system').args; | |
var URL = args[1]; | |
var FILE = args[2]; | |
var W = args[3]; | |
var H = args[4]; | |
if (URL && FILE && W && H) { | |
var page = require('webpage').create(); | |
page.viewportSize = { width: W, height: H }; | |
page.clipRect = { top: 0, left: 0, width: W, height: H }; | |
page.open(URL, function() { | |
page.render(FILE); | |
phantom.exit(); | |
}); | |
} else { | |
console.error('Usage: "./render.js site.com file.png W H"'); | |
phantom.exit(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment