Skip to content

Instantly share code, notes, and snippets.

@fajran
Created April 12, 2011 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fajran/916235 to your computer and use it in GitHub Desktop.
Save fajran/916235 to your computer and use it in GitHub Desktop.
import sys
import cairo
import rsvg
def main():
fin = sys.argv[1]
fout = sys.argv[2]
svg = rsvg.Handle(file=fin)
width = svg.props.width
height = svg.props.height
print 'Size:', (width, height)
surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height)
ctx = cairo.Context(surface)
svg.render_cairo(ctx)
surface.write_to_png(fout)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment