1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#!/usr/bin/env python
import gd, os, cStringIO, urllib2, sys
fontlist = [
'/usr/lib/python/site-packages/reportlab/fonts/PenguinAttack.ttf'
'/usr/share/fonts/truetype/freefont/FreeSans.ttf',
'/usr/share/fonts/truetype/ttf-bitstream-vera/Vera.ttf',
]
fontpath = '.'
for f in fontlist:
if os.path.exists(f):
fontpath = fontpath + ':' + os.path.dirname(f)
FONT = os.path.basename(f)
break
os.environ["GDFONTPATH"] = fontpath
try:
FONT
except NameError:
print "no fonts found"
sys.exit(1)
def simple():
im = gd.image((20,200))
white = im.colorAllocate((255, 255, 255))
black = im.colorAllocate((0, 0, 0))
#im.colorTransparent(white)
im.interlace(1)
im.string_ttf(FONT, 10.0, 1.56, (15, 190), sys.argv[1], black)
f=open(sys.argv[1]+".png","w")
im.writePng(f)
f.close()
simple()
|