Faça capturas de tela responsivas com phantomjs

Requer assíncrono; npm install async ou inclua em seu arquivo package.json.

var async = require('async'),
sizes
= [
[320, 480],
[320, 568],
[800, 600],
[600, 1024],
[1024, 768],
[1136, 640],
[640, 1136],
[720, 1280],
[1280, 720],
[1280, 800],
[1440, 900],
[1920, 1080],
[1080, 1920]
],
args
= require('system').args,
address
= '',
dirdump
= './screenshots/',
UAgent = 'Googlebot/2.1 (+http://www.googlebot.com/bot.html)';

args
.forEach(function(arg, i) {
if(i == 1) {
address
= arg;
}
});

function capture(sizes, callback) {
var page = require('webpage').create();
page
.settings.userAgent = UAgent';

// Run The Array

page.viewportSize = {

width: sizes[0],

height: sizes[1]

};


page.zoomFactor = 1;

page.open(address, function (status) {

var filename = sizes[0] + '
x' + sizes[1] + '.png';
page.render(dirdump + filename);

page.close();

callback.apply();

});

}


async.eachSeries(sizes, capture, function (e) {

if (e) console.log(e);

console.log('
done!');
phantom.exit();

});