Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added page.clipRect for rasterizing via PhantomJS #45

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions lib/converter.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function convert(resize) {
var dimensions = getSVGDimensions(page);
if (!dimensions) {
console.error("Width or height could not be determined from either the source file or the supplied " +
"dimensions");
"dimensions");
phantom.exit();
return;
}
Expand All @@ -43,16 +43,23 @@ function convert(resize) {
width: dimensions.width,
height: dimensions.height
};
page.clipRect = {
top: 0,
left: 0,
width: dimensions.width,
height: dimensions.height
};
page.open(PREFIX + sourceBase64, function (status) {
var result = "data:image/png;base64," + page.renderBase64("PNG");
system.stdout.write(result);
phantom.exit();
})
} catch (e) {
console.error("Unable to calculate or set dimensions.");
console.error(e);
phantom.exit();
return;
}

var result = "data:image/png;base64," + page.renderBase64("PNG");
system.stdout.write(result);
phantom.exit();
});
}

Expand Down