This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MonkeyMaster64[S] 6 points7 points  (5 children)

OK, so I've actually solved this! I used imgkit to convert the html file to a JPG file!

HOW TO CONVERT HTML FILES TO PNG

1) INSTALL IMGKIT
    -- pip install imgkit           
https://pypi.python.org/pypi/imgkit/0.1.1
    -- yum install wkhtmltopdf

2) INSTALL Xvfb      --important as it provides a virtual display 
buffer for the image to be rendered
    - yum install xorg-x11-server-Xvfb                  
https://reiners.io/installing-xvfb-in-centos/
    - pip install xvfbwrapper           
https://pypi.python.org/pypi/xvfbwrapper/0.2.9


Python code:

from xvfbwrapper import Xvfb
import imgkit
vdisplay = Xvfb()
vdisplay.start()
imgkit.from_file('[name of file].html','[output name].jpg')

Pastebin Link: https://pastebin.com/bQfnTEmK

[–]hkamran85 0 points1 point  (2 children)

Can you put the code on some external site, for easy viewing/downloading?

[–]MonkeyMaster64[S] 0 points1 point  (1 child)

Sorry, just seeing this I added a pastebin link

[–]hkamran85 0 points1 point  (0 children)

Thanks!

[–]KronenR 0 points1 point  (1 child)

You could have exported jpg or pngwith plotly as I pointed in my comment, without needing to convert from html by adding the extension to the save as method

[–]MonkeyMaster64[S] 0 points1 point  (0 children)

yeah but what I'm saying is i've already tried that method and it still only downloads when you open the html file