2 # -*- coding: utf-8 -*-
7 TEMPLATE='<?xml version="1.0" standalone="no"?>
8 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
9 "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
10 <svg width="800" height="600" version="1.1"
11 xmlns="http://www.w3.org/2000/svg"
12 xmlns:xlink="http://www.w3.org/1999/xlink">
13 <rect width="800" height="600"
14 style="fill:rgb(0,0,0);"/>
15 <rect x="99" y="49" width="602" height="402"
16 style="stroke:rgb(255,255,255);stroke-width:1;"/>
17 <image x="100" y="50" width="600px" height="400px"
19 <text text-anchor="middle" x="50%%" y="510"
20 font-family="Verdana" font-size="55"
21 style="fill:rgb(255,255,255);">
24 <text text-anchor="middle" x="50%%" y="550"
25 font-family="Verdana" font-size="30"
26 style="fill:rgb(255,255,255);">
30 printf "$TEMPLATE" "$1" "$2" "$3" | convert - "$4"
31 # ./generator.sh <картинка> <заголовок> <текст> <итоговая картинка.png>
35 _file
, title
, text
, out
= argv
[0], argv
[1], argv
[2], argv
[3]
37 template
= '''<?xml version="1.0" standalone="no"?>
38 <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
39 "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
40 <svg width="800" height="600" version="1.1"
41 xmlns="http://www.w3.org/2000/svg"
42 xmlns:xlink="http://www.w3.org/1999/xlink">
43 <rect width="800" height="600"
44 style="fill:rgb(0,0,0);"/>
45 <rect x="99" y="49" width="602" height="402"
46 style="stroke:rgb(255,255,255);stroke-width:1;"/>
47 <image x="100" y="50" width="600px" height="400px"
49 <text text-anchor="middle" x="50%%" y="510"
50 font-family="Verdana" font-size="55"
51 style="fill:rgb(255,255,255);">
54 <text text-anchor="middle" x="50%%" y="550"
55 font-family="Verdana" font-size="30"
56 style="fill:rgb(255,255,255);">
59 </svg>'''%(_file
,title
,text
)
60 print os
.popen('echo "%s" | convert - %s'%(template
, out
)).read()