Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Controlling DPI of image output using render()

Using phantomjs, is there a way to control the DPI setting used when rasterizing an image of the web content using the page.render(filename) method?

I can't find anything that would control this via the interface api, but didn't know if someone has already figured out a way to do this.

Our business-case looks like this:

Custom HTML content created via a web application is fed to our rasterize.js phantom process and is queried for a specific tag to set the client rectangle. This client rectangle is rendered to a PNG of the HTML that can then be used as an image elsewhere.

We want the resolution of the resulting PNG to be something higher than the default, due to aliasing on the text at some odd font sizes/bold combinations.

like image 947
Thomas Jones Avatar asked Jun 07 '12 16:06

Thomas Jones


1 Answers

I may be mixing up DPI with something else, but have you looked into the zoomFactor option? Setting that on the page object will cause the rendered image to zoomed.

like image 162
Henrik Aasted Sørensen Avatar answered Sep 23 '22 15:09

Henrik Aasted Sørensen