Browse Source

Add a dpi parameter to render_to_png

pull/28/merge
Guillaume Ayoub 12 years ago
parent
commit
063a895984
  1. 5
      pygal/ghost.py

5
pygal/ghost.py

@ -103,10 +103,11 @@ class Ghost(object):
with io.open(filename, 'w', encoding='utf-8') as f:
f.write(self.render(is_unicode=True))
def render_to_png(self, filename=None):
def render_to_png(self, filename=None, dpi=72):
"""Render the graph, convert it to png and write it to filename"""
import cairosvg
return cairosvg.svg2png(bytestring=self.render(), write_to=filename)
return cairosvg.svg2png(
bytestring=self.render(), write_to=filename, dpi=dpi)
def _repr_png_(self):
"""Display png in IPython notebook"""

Loading…
Cancel
Save