- 帖子
- 4
- 精华
- 0
- 积分
- 36
- 阅读权限
- 10
- 注册时间
- 2013-12-18
- 最后登录
- 2014-9-1
|
- # coding=gbk
- import Image, ImageDraw
- import ImageFont
- im = Image.open("a.jpg")
- # Creates an object that can be used to draw in the given image.
- draw = ImageDraw.Draw(im)
- # draw.line(xy, options) => Draws a line between the coordinates in the xy list.
- # The coordinate list can be any sequence object containing either 2-tuples [ (x, y), ... ]
- # or numeric values [ x, y, ... ].
- # The fill option gives the color to use for the line.
- draw.line((0, 0) + im.size, fill=128)
- draw.line((0, im.size[1], im.size[0], 0), fill=128)
- ttFont = ImageFont.truetype ("arial.ttf", 16)
- draw.text ((10, 10), "Hello", fill=(255,0,0), font=None)
- del draw
- # write to stdout
- im.save("b.jpg")
复制代码 这是我的代码,我用的是PIL-1.1.7.win32-py2.7.exe
现在我图片上想加文字
英文是OK的,可是把hello换成中文就乱码了.而且图片的font也不好用
先生能给个例子之类的吗,最近这个问题很头疼 谢啦 |
|