Black Lives Matter. Please consider donating to Black Girls Code today.

Auto-create PNG files

Hi, my app produces hundreds of HTML files with Plotly plots. The approach is very useful and efficient if I want to check how my code works with different configuration of input parameters. I just need to run the code and HTML files in a browser. Lots of fun!

But now I need to advance to the next level.

I need to include the Plotly plots I have into a LaTeX file. And here is the problem. For every HTML file, I open it in a browser, click on the export icon, type a file name, and save it. Repeated hundred times. Not fun. I wonder, can it be done automatically in a script? It is perfectly fine if I do this in nodejs/python (or something else) environment. I just want to have a script which takes an HTML file as the input, and produces a PNG file as the output.

Any suggestions? Thanks a lot!

Hi @WarShoe welcome to the forum! The Python library can save plotly figures to various static image formats, including png, thanks to the orca tool. The tutorial on static image export explains how to install orca and how to save figures in png. If your app uses the plotly.js library, you can save the plotly figures as json files from your app, and then open the json files from the Python library using