Created
June 27, 2014 08:14
-
-
Save sqndr/8c04cf0473ce3929f6b3 to your computer and use it in GitHub Desktop.
Phantom Responsive.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Needs phantomjs and async.