]> git.pld-linux.org Git - packages/librsvg.git/blame - rsvg
- updated to 2.50.3
[packages/librsvg.git] / rsvg
CommitLineData
290dc84d 1#!/usr/bin/python3
c2e97a8f
AO
2
3#
4# This python script subsumes the old 'rsvg' C-based command-line program.
5# It should be considered deprecated in favor of 'rsvg-convert'.
6#
7
8import getopt, sys, os
9
10def usage():
11 print >> sys.stdout, """Usage: rsvg [-v?] [-d|--dpi-x <float>] [-p|--dpi-y <float>]
12 [-x|--x-zoom <float>] [-y|--y-zoom <float>] [-w|--width <int>]
13 [-h|--height <int>] [-q|--quality <int>] [-f|--format [png, jpeg]]
14 [-v|--version] [-?|--help] [--usage] [OPTIONS...] file.svg file.png"""
15
16def help():
17 print >> sys.stdout, """Usage: rsvg [OPTIONS...] file.svg file.png
18 -d, --dpi-x=<float> pixels per inch
19 -p, --dpi-y=<float> pixels per inch
20 -x, --x-zoom=<float> x zoom factor
21 -y, --y-zoom=<float> y zoom factor
22 -w, --width=<int> width
23 -h, --height=<int> height
24 -q, --quality=<int> JPEG quality
25 -f, --format=[png, jpeg] save format
26 -v, --version show version information
27
28Help options:
29 -?, --help Show this help message
30 --usage Display brief usage message
31""",
32
33def shellEscape(param):
34 """Escape a string parameter for the shell."""
35 return "'" + param.replace("'", "'\\''") + "'"
36
37def main():
38 try:
39 opts, args = getopt.getopt(sys.argv[1:], "d:p:x:y:w:h:q:f:v?", ["dpi-x=", "dpi-y=", "x-zoom=", "y-zoom=", "width=", "height=", "quality=", "format=", "version", "usage"])
40 except getopt.GetoptError:
41 help()
42 sys.exit(1)
43
44 command_str = ""
050413d2 45
c2e97a8f
AO
46 for o, a in opts:
47 if o in ("-v", "--version"):
48 print "rsvg version %s" % ("2.34.2")
49 sys.exit(0)
50 elif o in ("--usage"):
51 usage()
52 sys.exit(0)
53 elif o in ("-?", "--help"):
54 help()
55 sys.exit(0)
56 elif (o in ("-f", "--format")):
57 if a in ("jpg", "jpeg"):
58 print >> sys.stderr, "The JPEG output format is no longer supported"
59 sys.exit(1)
60 elif (o in ("-q", "--quality")):
61 print "The --quality option is no longer supported"
62 sys.exit(1)
63 else:
64 command_str += " " + shellEscape(o) + " " + shellEscape(a)
65
66 if len(args) != 2:
67 help()
68 sys.exit(1)
69
70 return os.system("%s %s -o %s %s" % (shellEscape(os.path.join("/usr", "bin", "rsvg-convert")), command_str, shellEscape(args[1]), shellEscape(args[0])))
71
72if __name__ == "__main__":
73 main()
This page took 0.060441 seconds and 4 git commands to generate.