当前位置:操作系统 > Unix/Linux >>

解决方法Uncaught exception ImagickException with message Unable to annotate image

在利用Imagick调用ImageMagick来处理图片的时候,ImagickDraw->setFont('arial.ttf'),设置字体,总是无效。这是因为ImageMagick没有能够安装freetype支持,解决方法:

安装 freetype: yum install freetype
重新编译安装 ImageMagick
重新启动 apache
附:FreeType库是一个完全免费(开源)的、高质量的且可移植的字体引擎,它提供统一的接口来访问多种字体格式文件,包括TrueType, OpenType, Type1, CID, CFF, Windows FON/FNT, X11 PCF等。支持单色位图、反走样位图的渲染。FreeType库是高度模块化的程序库,虽然它是使用ANSI C开发,但是采用面向对象的思想,因此,FreeType的用户可以灵活地对它进行裁剪。

--------------------------------------------

报错: Uncaught exception 'ImagickException' with message 'Unable to annotate image'

使用phpinfo 函数检查时,正常.但php代码调用时,出现如上报错,或者读取不了字体,去掉字体就出现上面的报错了.

原因:和 /usr/share/fonts 下字体有关 www.zzzyk.com

字体目录 /usr/share/fonts

ImageMagick 配置字体 /usr/local/lib/ImageMagick-6.5.1/config/type-ghostscript.xml ,若系统在字体目录下只有 bitstream-vera ,导致type-ghostscript.xml 配置中获取字体路径没有 如: <type name="AvantGarde-Book" fullname="AvantGarde Book" family="AvantGarde" foundry="URW" weight="400" style="normal" stretch="normal" format="type1" metrics="a010013l.afm" glyphs="a010013l.pfb"/> 正常的应该是: <type name="AvantGarde-Book" fullname="AvantGarde Book" family="AvantGarde" foundry="URW" weight="400" style="normal" stretch="normal" format="type1" metrics="/usr/share/fonts /default/Type1/a010013l.afm" glyphs="/usr/share/fonts/default/Type1/a010013l.pfb"/>

Uncaught exception 'ImagickException' with message 'Unable to annotate image'解决方法:

1、安装系统原有字体相关包:yum -y install bitmap-fonts xorg-x11-fonts-Type1 libfontenc bitstream-vera-fonts xorg-x11-fonts-base xorg-x11-font-utils urw-fonts fontconfig libXfont libXfontcache chkfontpath

2、重新编译 ImageMagick 和 imagick .

CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,