Skip to content

Instantly share code, notes, and snippets.

@parshap
Created November 11, 2012 21:17
Show Gist options
  • Save parshap/4056303 to your computer and use it in GitHub Desktop.
Save parshap/4056303 to your computer and use it in GitHub Desktop.
CasperJS capture screen
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();
@n1k0
Copy link

n1k0 commented Nov 12, 2012

// @todo Send the image to exploder

http://stackoverflow.com/a/13320598/330911 :)

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