【发布时间】:2015-10-31 00:28:46
【问题描述】:
我正在尝试使用 Imagemagick 和 PHP 生成多色文本图像。以下代码有效,但我无法在每个单词后插入空格。我尝试了各种设置,没有任何效果。我应该使用注释或绘制文本命令而不是标签吗?标签似乎在这里使用起来很简单。
$file = 'font.ttf';
$command = "convert -background white -fill black -font $file -pointsize 80 -density 90 label:New -fill black -font $file -pointsize 80 -density 90 label:Here -fill red -font $file -pointsize 80 -density 90 label:? +append $multi-color-text.png";
exec($command);
更新:解决方案
备注:空格在命令行中不起作用。所以,我需要用正斜杠转义双引号。
这已经奏效了:
$command = "convert -background white -fill black -font $file -pointsize 80 -density 90 label:\"New \" -fill black -font $file -pointsize 80 -density 90 label:\"Here \" -fill red -font $file -pointsize 80 -density 90 label:? +append $multi-color-text.png";
谢谢大家,尤其是 Fred!
【问题讨论】:
-
尝试使用
\n。不是100%肯定,但你可以试试。或连接"convert ... code... . " " . etc. -
嗨 Fred,我需要将所有这些词放在一行中。 '\n' 我认为会创建多行。
-
我对此有一种感觉。我在上面编辑了我的评论以尝试连接。 IE。
"convert . " " . etc事物的类型。 -
$multi-color-text应该是一个变量吗? -
@Phellipe,$multi-color-text 是一个变量。
标签: php imagemagick