Skip to content

Commit

Permalink
Merge pull request #21 from hilios/master
Browse files Browse the repository at this point in the history
Fix #20, Add the cliprect option to control the portion of the viewport that will be rendered
  • Loading branch information
superbrothers committed Feb 7, 2015
2 parents 35f56ed + 66d8dd8 commit 460121e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -31,6 +31,7 @@ Options:
-A, --user-agent <value> UserAgent
-J, --javascript-file <value> Inject external script code on Web page
-V, --viewportsize <value> ViewPortSize {width}x{height}
-C, --cliprect <value> ClipRect {top}x{left}x{width}x{height} that will be rendered
-c, --cookies-file <value> Cookies file
-T, --timeout <value> HTTP Timeout (ms)
-R, --renderdelay <value> Render delay (ms)
Expand Down
8 changes: 8 additions & 0 deletions lib/capturejs.js
Expand Up @@ -28,6 +28,14 @@ module.exports.capture = function (option, callback) {
}
}

// clipRect option
if (option.cliprect) {
matches = option.cliprect.match(/^(\d+)x(\d+)x(\d+)x(\d+)$/);
if (matches !== null) {
page.set("clipRect", {top: matches[1], left: matches[2], width: matches[3], height: matches[4]});
}
}

// UserAgent option
if (option["user-agent"]) {
page.set("settings.userAgent", option["user-agent"]);
Expand Down
2 changes: 2 additions & 0 deletions lib/cli.js
Expand Up @@ -18,6 +18,7 @@ cli.start = function (argv) {
"user-agent": String,
"javascript-file": path,
viewportsize: String,
cliprect: String,
"cookies-file": path,
timeout: Number,
renderdelay: Number,
Expand All @@ -34,6 +35,7 @@ cli.start = function (argv) {
A: "--user-agent",
J: "--javascript-file",
V: "--viewportsize",
C: "--cliprect",
c: "--cookies-file",
T: "--timeout",
R: "--renderdelay",
Expand Down

0 comments on commit 460121e

Please sign in to comment.