设为首页收藏本站

Crossin的编程教室

 找回密码
 立即加入
查看: 10971|回复: 1
打印 上一主题 下一主题

想请教先生一个问题,关于

[复制链接]

3

主题

0

好友

36

积分

新手上路

Rank: 1

跳转到指定楼层
楼主
发表于 2013-12-23 12:29:40 |只看该作者 |倒序浏览
  1. # coding=gbk
  2. import Image, ImageDraw
  3. import ImageFont
  4. im = Image.open("a.jpg")

  5. # Creates an object that can be used to draw in the given image.
  6. draw = ImageDraw.Draw(im)

  7. # draw.line(xy, options) => Draws a line between the coordinates in the xy list.

  8. # The coordinate list can be any sequence object containing either 2-tuples [ (x, y), ... ]
  9. # or numeric values [ x, y, ... ].
  10. # The fill option gives the color to use for the line.
  11. draw.line((0, 0) + im.size, fill=128)
  12. draw.line((0, im.size[1], im.size[0], 0), fill=128)
  13. ttFont = ImageFont.truetype ("arial.ttf", 16)
  14. draw.text ((10, 10), "Hello", fill=(255,0,0), font=None)
  15. del draw

  16. # write to stdout
  17. im.save("b.jpg")
复制代码
这是我的代码,我用的是PIL-1.1.7.win32-py2.7.exe
现在我图片上想加文字
英文是OK的,可是把hello换成中文就乱码了.而且图片的font也不好用
先生能给个例子之类的吗,最近这个问题很头疼 谢啦
回复

使用道具 举报

174

主题

45

好友

11万

积分

管理员

Rank: 9Rank: 9Rank: 9

沙发
发表于 2013-12-24 10:41:53 |只看该作者
在那个帖里回复了,可能是没用中文字体的原因
#==== Crossin的编程教室 ====#
微信ID:crossincode
网站:http://crossincode.com
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即加入

QQ|手机版|Archiver|Crossin的编程教室 ( 苏ICP备15063769号  

GMT+8, 2024-6-26 19:54 , Processed in 0.022228 second(s), 24 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部