Skip to content

Instantly share code, notes, and snippets.

@sqndr
Created June 27, 2014 08:14
Show Gist options
  • Save sqndr/8c04cf0473ce3929f6b3 to your computer and use it in GitHub Desktop.
Save sqndr/8c04cf0473ce3929f6b3 to your computer and use it in GitHub Desktop.
Phantom Responsive.
var async = require('async');
var sizes = [
[320, 480],
[600, 1024],
[1024, 768],
[1280, 800],
[1440, 900]
];
var url = 'http://one-pager.dev/nl';
function capture(sizes, callback) {
var page = require('webpage').create();
page.viewportSize = {
width: sizes[0],
height: sizes[1]
};
page.zoomFactor = 1;
page.open(url, function (status) {
var filename = sizes[0] + 'x' + sizes[1] + '.png';
page.render('./screenshots/' + filename);
console.log('I\'ve created /screenshots/' + sizes[0] + 'x' + sizes[1] + '.png');
page.close();
callback.apply();
});
}
console.log('Hi, welcome to the responsive webpage tester.');
console.log('Let me create some screenshots for you!');
async.eachSeries(sizes, capture, function (e) {
if (e) console.log(e);
console.log('Done creating the screenshots!');
console.log('Have a nice day!');
phantom.exit();
});
@sqndr
Copy link
Author

sqndr commented Jun 27, 2014

Needs phantomjs and async.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment