-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget-screen.js
40 lines (29 loc) · 853 Bytes
/
get-screen.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
29
30
31
32
33
34
35
36
37
38
39
40
/* You must use ./node_modules/.bin/phantomjs server-v4.js */
var system = require('system');
var page = require('webpage').create();
var args = system.args;
var url = 'http://todomvc.com';
var screenSize = [1920,1080];
var cropCoordinates = [0, 0];
var finalSize = [256, 256];
var filename = 'result.png';
page.viewportSize = {
width: screenSize[0],
height: screenSize[1],
};
args.forEach(function (val, index) {
if(index == 1){
url = val;
}
});
page.open(url, function(status){
if(status == 'success'){
page.clipRect = { top: cropCoordinates[0], left: cropCoordinates[1], width: finalSize[0], height: finalSize[1] };
setTimeout(function() {
page.render(filename);
phantom.exit();
}, 200);
} else {
console.log('Unable to load the address!');
}
});