Created
November 11, 2012 21:17
-
-
Save parshap/4056303 to your computer and use it in GitHub Desktop.
CasperJS capture screen
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 casper = require("casper").create(); | |
// Maximum size of capture | |
var MAX_WIDTH = 1000, | |
MAX_HEIGHT = 1500; | |
casper.start("http://www.google.com", function() { | |
// Figure out how big the BODY element of the document is | |
var bounds = this.getElementBounds("body"), | |
width = Math.min(bounds.width, MAX_WIDTH), | |
height = Math.min(bounds.height, MAX_HEIGHT); | |
this.viewport(width, height); | |
var image = this.captureBase64("png", { | |
top: 0, | |
left: 0, | |
width: width, | |
height: height, | |
}); | |
// @TODO Send the image to exploder | |
}); | |
casper.run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://stackoverflow.com/a/13320598/330911 :)