Skip to content

Instantly share code, notes, and snippets.

@kopiro
Created August 24, 2015 10:48
Show Gist options
  • Save kopiro/37702a8b0b40a716e6e7 to your computer and use it in GitHub Desktop.
Save kopiro/37702a8b0b40a716e6e7 to your computer and use it in GitHub Desktop.
PhantomJS Renderer
#!/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