File: svg_to_png.py

package info (click to toggle)
lxpanel 0.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 10,136 kB
  • sloc: ansic: 33,536; makefile: 541; xml: 310; python: 62; sh: 26
file content (15 lines) | stat: -rwxr-xr-x 523 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import os, re, argparse, glob, gtk


parser = argparse.ArgumentParser()
parser.add_argument("width", help="destination width", type=int)
parser.add_argument("height", help="destination height", type=int)
args = parser.parse_args()
svg_files = glob.glob("*.svg")
for svg_file in svg_files:
    pixbuf = gtk.gdk.pixbuf_new_from_file(svg_file)
    new_pixbuf = pixbuf.scale_simple(args.width, args.height, gtk.gdk.INTERP_HYPER)
    new_pixbuf.save(svg_file[:-3] + "png" , "png")