简体   繁体   English

PHP ImageMagick exec-绘制文本无法正常工作-特殊字符

[英]php ImageMagick exec -draw text doesn't work as expected - special characters

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, … output.png仅显示“ Khle”……因此,特殊字符,空格,引号等必定存在问题。

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! 谢谢!

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). 至于特殊字符,请尝试以unif utf-8格式保存脚本(当显示保存对话框时,诸如Textpad之类的编辑器具有用于保存文件的选项,相似的编辑器应具有相同的选项)。

And set the system LANG to use utf 并将系统LANG设置为使用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 还需要在一行上,否则它将解释为单独的命令

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM