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

时间:2021-07-15 09:00:08
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!

我现在已经失去了很多时间......所以这就是为什么我希望你能帮助我。谢谢!

1 个解决方案

#1


1  

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).

至于特殊字符,请尝试以unix utf-8格式保存脚本(像Textpad这样的编辑器具有保存文件的选项,因为在显示保存对话框时,类似的编辑器应该具有相同的选项)。

And set the system LANG to use utf

并将系统LANG设置为使用utf

LANG=en_US.utf-8;

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

看起来你想要'标签'而不是画画。它也需要在一行上,否则它会将其解释为单独的命令

#1


1  

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).

至于特殊字符,请尝试以unix utf-8格式保存脚本(像Textpad这样的编辑器具有保存文件的选项,因为在显示保存对话框时,类似的编辑器应该具有相同的选项)。

And set the system LANG to use utf

并将系统LANG设置为使用utf

LANG=en_US.utf-8;

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

看起来你想要'标签'而不是画画。它也需要在一行上,否则它会将其解释为单独的命令