专注收集记录技术开发学习笔记、技术难点、解决方案
网站信息搜索 >> 请输入关键词:
您当前的位置: 首页 > Perl/Python

高手,帮小弟我看看这个PIL的有关问题吧

发布时间:2011-06-29 20:11:12 文章来源:www.iduyao.cn 采编人员:星星草
高手,帮我看看这个PIL的问题吧
我就是想实现在图片上添加一些文字的功能,但是总是不成功
我试了试windws下的python2.6和PIL1.6版本的可以,但是在linux下不行,
会报下面的这个错误

不知道应该怎么解决,各位帮一下忙啊,谢谢啦

[zk@localhost ~]$ python
Python 2.6.4 (r264:75706, Apr 1 2010, 02:56:02) 
[GCC 4.4.3 20100226 (Red Hat 4.4.3-8)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import ImageFont
>>> font = ImageFont.truetype('simsun.ttc',24)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.6/site-packages/PIL/ImageFont.py", line 205, in truetype
  return FreeTypeFont(filename, size, index, encoding)
  File "/usr/lib/python2.6/site-packages/PIL/ImageFont.py", line 121, in __init__
  self.font = _imagingft.getfont(file, size, index, encoding)
IOError: cannot open resource 
>>>


------解决方案--------------------
simsun.ttc是windows带的字体。你可以从windows下拷贝一份,放到适当的地方,然后在Imagefont.truetype函数调用中用绝对路径。
友情提示:
信息收集于互联网,如果您发现错误或造成侵权,请及时通知本站更正或删除,具体联系方式见页面底部联系我们,谢谢。

其他相似内容:

热门推荐: