Solved:
if form.accepts(request.vars, session, keepvalues=True,
onvalidation=WriteThumb):
.........
def WriteThumb(form):
i = cStringIO.StringIO()
o = cStringIO.StringIO()
i.write(form.vars.imgfile.value)
i.seek(0)
im = Image.open(i, 'r')
im.thumbnail((100,100),Image.ANTIALIAS)
im.save(o,'jpeg')
form.vars.thumbnail = base64.b64encode(o.getvalue())
o.close()
i.close()
<img src="data:image/jpeg;base64,{{=row['thumbnail']}}"
alt="Thumbnail photo" />