import string import random import PIL from PIL import Image, ImageFont, ImageDraw from PIL import ImageEnhance, ImageOps, ImageStat from StringIO import StringIO import os
pwd = os.path.dirname(os.path.abspath(__file__)) fpath=os.path.join(pwd,'img.ttf') iname=os.path.join(pwd,'pass.jpg') def gen(): text = str(random.randint(0,1000)) im = Image.new("RGB", (125, 34), "#fff") ttf = ImageFont.truetype(fpath, 16) draw = ImageDraw.Draw(im) draw.text((10,10), text, font=ttf, fill="green") img = StringIO() im.save(img, "JPEG") f = open(iname) f.write(im) f.close() return text if __name__ == "__main__": print gen() [EMAIL PROTECTED]:~/Desktop/svn/xhtml$ python2.5 textimg.py Traceback (most recent call last): File "textimg.py", line 27, in <module> print gen() File "textimg.py", line 22, in gen f.write(im) TypeError: argument 1 must be string or read-only character buffer, not instance [EMAIL PROTECTED]:~/Desktop/svn/xhtml$ i am stuck anybody can help me ? -- http://mail.python.org/mailman/listinfo/python-list