question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to save png directly from python script?

See original GitHub issue

I note that when I do an Altair visualization (example.html), there’s an “export PNG” button beneath it. Can I call this straight from python? I’d like to be able to:

open('example.html', 'w').write(chart.to_html())
open('example.png', 'w').write(chart.to_png())

but that does not appear to be possible, and I can’t obviously see how to export png from python directly.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:2
  • Comments:12 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
johanoviccommented, Feb 3, 2020

Is there three years later maybe a native way to save altair/vega figures to png/jpeg/svg without a headless browser?

Many thanks for your great work

1reaction
jakevdpcommented, Feb 2, 2021

A possible approach is to save charts without a headless browser is to use Kaleido; tracking issue is here: https://github.com/altair-viz/altair_saver/issues/85

The main challenge is finding someone who wants to put in the time to try it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Loading and Saving Images in Python | by Renu Khandelwal
You can save the JPEG image in a different format like PNG using save() of the PIL img_PIL.save(r'\dogs-v-cats\dog.1.png') ...
Read more >
Save plot to image file instead of displaying it using Matplotlib
When using matplotlib.pyplot.savefig , the file format can be specified by the extension: from matplotlib import pyplot as plt plt.savefig('foo.png') ...
Read more >
How to download an image with Python? - ScrapingBee
This tutorial will show you how to download and save images with Python from URL. There are different librairies that can help you...
Read more >
Python script to convert scripts to png files
I have written a Python script that converts scripts to png files, entirely by myself without anybody's help.
Read more >
Convert Image To PNG Python - Aspose
1. Install 'Aspose.Words for Python via .NET'. 2. Add a library reference (import the library) to your Python project. 3. Open the source...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found