Skip to content

Instantly share code, notes, and snippets.

@westonwatson
Created January 28, 2013 23:52
Show Gist options
  • Save westonwatson/4660436 to your computer and use it in GitHub Desktop.
Save westonwatson/4660436 to your computer and use it in GitHub Desktop.
var page = require('webpage').create(),
address, output, size, timeOut, loops, cnt;
if (phantom.args.length < 2 || phantom.args.length > 6) {
console.log('Usage: westerize.js URL filename [timeout] [repeat] [width] [height]');
console.log(' timeout: miliSeconds');
console.log(' repeat: how many images to take');
console.log(' width/height: defaults to 1024x768');
phantom.exit();
} else {
address = phantom.args[0];
output = phantom.args[1];
timeOut = phantom.args[2]?phantom.args[2]:200;
loops = phantom.args[3]?phantom.args[3]:1;
page.viewportSize = { width: phantom.args[4]?phantom.args[4]:1024, height: phantom.args[5]?phantom.args[5]:768 };
cnt = 0;
page.open(address, function (status) {
if (status !== 'success') {
console.log('Unable to load the address!');
} else {
window.setInterval(function () {
console.log(cnt+', '+loops);
// return;
var frameFilename = 'frame_'+(cnt?cnt:'0')+'_'+output;
page.render(frameFilename.toString());
if (cnt++ > loops) phantom.exit();
}, timeOut);
}
});
}
@westonwatson
Copy link
Author

westerize.js

simple phantomjs script for taking multiple screenshots. great for capturing effects, motion, etc...

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