dousaoxiancy199896 2013-06-27 07:56
浏览 47
已采纳

php ImageMagick exec -draw文本无法正常工作 - 特殊字符

exec($IM_path."convert
    -size 800x300 xc:black  
    -font ".$linktottf."
    -pointsize 16
    -draw \"fill white stroke none decorate underline text 580,28 Kühle Frische, not working\"
    output.png");

The "draw text"-part in the code above doesn't work. the output.png displays only "Khle" … so there must be a problem with Special Characters, Whitespaces, Quotes, …

I tried a lot (escaping, different quotes, backslashes, …)

I've lost a lot of time now … so this is why I hope you could help me. Thx!

  • 写回答

1条回答 默认 最新

  • doumi7861 2013-06-27 08:12
    关注

    if you want the quotes drawn as well you need to enclose them in a different set of quotes, double quotes wrapped in single quotes.

    label:'\"fill white stroke none decorate underline text 580,28 Kühle Frische, not working\"'
    

    As for the special characters try saving your script in unix utf-8 format (editors like Textpad have options for saving files as these when showing the save dialog, similar editors should have the same option).

    And set the system LANG to use utf

    LANG=en_US.utf-8;

    exec("LANG=en_US.utf-8; ".$IM_path."convert -size 800x300 xc:black -font ".$linktottf." -pointsize 16 label:'\"fill white stroke none decorate underline text 580,28 Kühle Frische, not working\"' output.png");
    

    Looks like you want 'label' and not draw. also it needs to be on one line otherwise it will interpret it as separate commands

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

报告相同问题?

悬赏问题

  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,
  • ¥15 我的代码无法在vc++中运行呀,错误很多
  • ¥50 求一个win系统下运行的可自动抓取arm64架构deb安装包和其依赖包的软件。
  • ¥60 fail to initialize keyboard hotkeys through kernel.0000000000
  • ¥30 ppOCRLabel导出识别结果失败