Beispiel #1
0
    def writePNG(self, filename, width=-1, height=-1, scale=1.):
        '''
        render to png file
        '''
        if CairoSVG is None:
            raise ImportError('cairo extension not available')

        if isinstance(filename, basestring):
            fh = open(filename, 'wb')
        else:
            fh = filename

        svgfh = StringIO()
        self.write(svgfh)
        svgfh.seek(0)

        writer = CairoSVG(svgfh)
        writer.toPNG(fh, width, height, scale)
Beispiel #2
0
 def writePNG(self, filename, width = -1, height = -1, scale = 1.):
     '''
     render to png file
     '''
     if CairoSVG is None:
         raise ImportError('cairo extension not available')
     
     if isinstance(filename, basestring):
         fh = open(filename, 'wb')
     else:
         fh = filename
         
     svgfh = StringIO()
     self.write(svgfh)
     svgfh.seek(0)
     
     writer = CairoSVG(svgfh)
     writer.toPNG(fh, width, height, scale)