Question

Im using wkhtmltoimage to grab an screenshot from a webserver and It always gets 1024px png images. What could I be doing wrong?

/usr/bin/xvfb-run.sh --server-args="-screen 0, 1280x1024x32 -ac +extension GLX +render" wkhtmltoimage --use-xserver -f png --quality 83 --javascript-delay 1000 --transparent ' http://www.whatever.com screenshot.png
Was it helpful?

Solution

The screen resolution specified in the xvfb-run command is 1280x1024, so the grabbed screenshot will be 1280x1024 as well. You can change the resolution of the emulated screen or crop the image using parameters on the wkhtmltoimage command. Quoting the wkhtmltoimage manual:

--crop-h    <int>   Set height for croping
--crop-w    <int>   Set width for croping
--crop-x    <int>   Set x coordinate for croping
--crop-y    <int>   Set y coordinate for croping
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top