Created
January 28, 2013 23:52
-
-
Save westonwatson/4660436 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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); | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
westerize.js
simple phantomjs script for taking multiple screenshots. great for capturing effects, motion, etc...