duanqiao1926 2011-08-16 12:34
浏览 100
已采纳

Imagemagick不会显示文本,但也不会抛出任何错误

I'm using ImageMagick to generate some product badges for products in our system. Product badges are like SO flair, just a few composite images and some text. There is nothing wrong with the script as it runs fine on my development machine which runs Windows. However, on my production system (CentOS 5.1), it renders everything except the text.

I thought this was a font issue, but it doesn't work even if I copy the font file to the PHP file location nor did it work when I gave it a full path.

And it didn't work when I installed the Windows fonts for Linux as described here.

I've typed convert -list font and it shows a list of fonts that Imagick knows about (parital list shown below)

  Font: Times-BoldItalic
    family: Times
    style: Italic
    stretch: Normal
    weight: 700
    glyphs: /usr/share/fonts/default/Type1/n021024l.pfb
  Font: Times-Italic
    family: Times
    style: Italic
    stretch: Normal
    weight: 400
    glyphs: /usr/share/fonts/default/Type1/n021023l.pfb
  Font: Times-Roman
    family: Times
    style: Normal
    stretch: Normal
    weight: 400
    glyphs: /usr/share/fonts/default/Type1/n021003l.pfb

I tried giving the absolute path listed here and it didn't work. I also tried just using the name and still nothing.

Basically the image shows up, but the text parts of it don't show up at all and no errors are thrown (see images below).

There's nothing wrong with the code and both Windows and CentOS are running close versions of Imagick (6.7.1-4 and 6.7.1-3). The only issue could be the font, I'm just putting normal TTF fonts up and testing, do I need some kind of special font to get it to work?

Working

Working Image

Broke

Broken Image

EDIT - Ignore the differences in the QR code and the ratings. This is due to the working badge and the non working badge being on two different servers.

UPDATE 1 - I've run a simple test script and even that doesn't work. This is what I ran as a test : http://us2.php.net/manual/en/function.imagick-annotateimage.php The font just doesn't show up and no errors are thrown.

I've also copied a font from the CentOS system and tried it on the Windows box and it works fine. Fonts simply don't seem to work on CentOS.

I've also tried it without setting a font, I assume Imagick picks up a default font or something, and again works on Windows, but not on CentOS. I'm going to try this on a different *nix version to see what happens. Will update with findings.

Update 3 : I've narrowed the issue down to a problem with the FreeType library I think. The forums say that FreeType needs to be installed for text to be displayed properly. And when I look at the config.log it tells me that there is an issue installing FreeType. Any heads up on this would be appreciated, meanwhile I'm going to re-install Freetype and run the installation again.

  • 写回答

1条回答 默认 最新

  • doupinyan0186 2011-08-18 18:24
    关注

    You can't just install Freetype. You actually have to install Freetype on your server, then recompile ImageMagick using the --with-freetype-dir=/usr/local option. Where /usr/local is the path to your Freetype install.

    I believe it's normally /usr/local/bin

    Give that a whirl and let us know what happens ;)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度