forked from geek-at/http2pic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphantom.js
28 lines (24 loc) · 804 Bytes
/
phantom.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var page = require('webpage').create(),
system = require('system'),
address, output, size;
var input = system.args[1].split(",");
address = input[0];
output = input[1];
var vp_w = input[2];
var vp_h = input[3];
var js = input[4];
var pageWidth = (vp_w!="")?parseInt(vp_w, 10):1024;
var pageHeight = (vp_h!="")?parseInt(vp_h, 10):'auto';
page.viewportSize = { width: pageWidth, height: pageHeight };
page.settings['javascriptEnabled'] = (js=="no")?false:true;
page.open(address, function (status) {
if (status !== 'success') {
console.log('Unable to load the address!');
phantom.exit(1);
} else {
window.setTimeout(function () {
page.render(output);
phantom.exit();
}, 200);
}
});