duanlinzhen7235 2015-10-31 00:28
浏览 42

在多色文本图像中的每个单词之间添加空格

I am trying to produce multi-colored text image with Imagemagick and PHP. The following code works, but I cannot insert a space after each word. I have tried various settings, nothing is working. Should I use annotate or draw text command instead of label? Label seems to be simple to use here.

$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);

Update: Solution

Remarks: Spaces do not work in command line. So, I need to escape double quotes with a forward slash.

This has worked:

$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";

Thank you all, especially Fred!

  • 写回答

1条回答 默认 最新

  • douqin3245 2015-10-31 00:57
    关注

    In your case it seems like it would be better to use -annotate once you want to insert multiple texts instead of using -label.

    Example of use of -annotate: http://www.imagemagick.org/Usage/annotating/#gravity_text

    评论

报告相同问题?

悬赏问题

  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 如何提取csv文件中需要的列,将其整合为一篇完整文档,并进行jieba分词(语言-python)
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL
  • ¥15 扩散模型sd.webui使用时报错“Nonetype”
  • ¥15 stm32流水灯+呼吸灯+外部中断按键
  • ¥15 将二维数组,按照假设的规定,如0/1/0 == "4",把对应列位置写成一个字符并打印输出该字符
  • ¥15 NX MCD仿真与博途通讯不了啥情况
  • ¥15 win11家庭中文版安装docker遇到Hyper-V启用失败解决办法整理
  • ¥15 gradio的web端页面格式不对的问题