【问题标题】:How to use pango in script with imagemagick如何在带有 imagemagick 的脚本中使用 pango
【发布时间】:2018-08-31 20:26:25
【问题描述】:

这是我目前使用的代码的简化版本:

cat $FILES | while read line; do
     convert -fill $FG_COLOR -background $BG_COLOR \
         -size ${line_width}x${line_height} -page +${x_margin}+${y} \
         label:"${varL} and ${varR}" miff:-
done | convert -size ${SCREEN_W}x${SCREEN_H} xc:$BG_COLOR - -flatten image.jpg

而且运行良好!

但我希望${varL}${varR} 有不同的颜色,我想我应该使用pango 而不是label。我说的对吗?

但是通过保留相同的代码并将label 替换为pango,我遇到了一个意外错误:

convert-im6.q16: width or height exceeds limit

【问题讨论】:

  • ${line_width}x${line_height} 变量有多大?
  • 请务必将 shell 变量括在双引号中,以避免出现 rgb(0,0,0) 等颜色问题和带有空格的文件名导致扩展问题。我的意思是convert -fill "$FG_COLOR" -background "$BG_COLOR" ...
  • 颜色很简单,例如“黑色”或“白色”,但感谢您的建议。 ${line_width}x${line_height} 约为 785x14,似乎并不过分...页面约为 +10+336 左右
  • 如果我删除 -size ... 没有错误,但也只是一个没有文本的空行,并且输入 pango':<span foreground="red">TEST</span>' 不会改变任何内容。

标签: imagemagick pango


【解决方案1】:

我很困惑我是如何解决这个问题的。

无论如何,事情是这样的:我不知道为什么,但是 pango 需要在其他参数之前。

convert -fill $FG_COLOR -background $BG_COLOR \
         -size ${line_width}x${line_height} -page +${x_margin}+${y} \
         pango:"${varL} and ${varR}" miff:-

不工作,但是:

convert pango:"${varL} and ${varR}" \
         -fill $FG_COLOR -background $BG_COLOR \
         -size ${line_width}x${line_height} -page +${x_margin}+${y} miff:-

正在工作!

编辑:pango: 必须在 -page 之前

【讨论】:

    猜你喜欢
    • 2021-10-28
    • 1970-01-01
    • 2022-12-22
    • 2023-03-19
    • 2012-02-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-10
    相关资源
    最近更新 更多