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

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

报告相同问题?

悬赏问题

  • ¥15 用三极管设计—个共射极放大电路
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示