Is there a ready-to-use program, that I can run from my web application, to convert an HTML file to an image? Preferably using Webkit, or another mature browser engine?
I tried wkhtmltoimage, but it doesn't render backgrounds correctly (while wkhtmltopd works fine). Is there one that works?
You can try webkit2png
:
Tested in Ubuntu
:
$ sudo apt-get install python-qt4 libqt4-webkit python-pip xvfb
$ wget https://raw.github.com/millisami/python-webkit2png/master/webkit2png.py
$ chmod +x webkit2png.py
$ sudo xvfb-run --server-args="-screen 0, 1024x768x24" ./webkit2png.py -o google.png http://www.google.com
This will create an image named google.png
UPDATE
Another easy way is using phantomjs
:
$ phantom rasterize.js http://www.google.com google.png
Download and unzip the binary archive. rasterize.js
is in the example
directory.