Es holt aus 5 Textfeldern die Eingabe raus, beschreibt damit eine bestimte Stelle des Bildes, speichert dieses in einem extra Ordner ab und erstellt noch eine HTML File .
Code: Alles auswählen
import Image, ImageDraw, ImageFont, os, cgi, re,cgitb
cgitb.enable()
form = cgi.FieldStorage()
name = form["name"].value
print name
#checks forms
lchlist=[0,0,0,0,0]
#lines
line1=form["line1"].value
line2=form["line2"].value
line3=form["line3"].value
line4=form["line4"].value
line5=form["line5"].value
#check if all fields are used
linecheck = 0
linenr = "1"
linelist=[line1,line2,line3,line4,line5]
check = 1
lch=[0,0,0,0,0]
while check :
try :
linelist[linecheck]=form["line"+linenr].value
except KeyError :
lch[linecheck]=1
linecheck = linecheck + 1
linenr = linenr + "1"
if linecheck < 5 :
check = 0
else : pass
#check if name already exists and creats dir
try : os.mkdir(name)
except :
print "Content-Type : text/html"
print
print "<Title>Failure</Title>"
print "Name already exists. Pleace go back and try another one. Thank you."
#prepare picture
im = Image.open("stupid.jpg")
font = ImageFont.truetype('arial.ttf', 18)
#write to picture
draw = ImageDraw.Draw(im)
dowrite = 0
pos = (20,155)
fak = 0
y = 155
while dowrite != 5 :
if not lch[dowrite] :
draw.text(pos, linelist[dowrite], font=font, fill=1)
dowrite = dowrite + 1
fak = fak + 1
pos = (20,fak*25+155)
im.save(name+'/test2.gif')
#make html
ohtml =open(name+"/index.html", "w")
ohtml.write("<img src=\"test2.gif\">")
ohtml.close()
print "Content-Type : text/html"
print
print "Pic Created"
print "URL :"
print "<a href=\"http://mrsexy.org/"+name+">http://mrsexy.org/"+name+"</a>"