A program that converts html to image

Is there a ready-made program that I can run from my web application to convert an HTML file to an image? Is it advisable to use Webkit or another mature browser engine?

I tried wkhtmltoimage but it does not display the background correctly (while wkhtmltopd is working fine). Is there one that works?

+10
source share
1 answer

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 called google.png


UPDATE

Another easy way is phantomjs :

 $ phantom rasterize.js http://www.google.com google.png 

Download and unzip the binary archive. rasterize.js is located in the example directory.

+19
source

Source: https://habr.com/ru/post/912586/


All Articles