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?
Converting HTML to JPG with the Windows screen capture tool Open your HTML file in your browser or any viewable tool. Take a snapshot of an area with your screen capture tool (Snipping tool on Windows, for example). Click File > Save as. Select the location and select the Save as type as JPG.
Method A
Using phantomjs
$ phantom rasterize.js http://www.google.com google.png
Download and unzip the binary archive. rasterize.js
is in the example
directory.
Method B
Using chrome (Tested on MacOSX
, should work on other platforms)
$ alias chrome='/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome'
$ chrome --headless --disable-gpu --screenshot=google.png http://www.google.com
Method C
Using webkit2png (macOS only)
simply use firefox
firefox --headless --screenshot google.com
or visit here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With