【问题标题】:Combining multiple images and text using ImageMagick使用 ImageMagick 组合多个图像和文本
【发布时间】:2017-07-12 21:14:40
【问题描述】:

我是 ImageMagick 的新手,我正在尝试将 3 个不同的标签添加到 3 个不同的(小)图像中,然后将它们插入到背景图像上,每个都在一个角落里。

所有图像和文本字符串都是事先未知的,这就是我编写脚本来处理它的原因。我最近(失败)的尝试是:

convert -page +0+0 ${bg}.png \
    \( -page +0+0 -gravity south  -pointsize 16 \
    -stroke '#000C' -strokewidth 4 -annotate 0 "$label" \
    -stroke  none   -strokewidth 20 -fill white    -annotate 0 "$label" \) \
    \( -page +0+0 ${im1}.png \
    -stroke '#000C' -strokewidth 2 -annotate 0 "text1" \
    -stroke  none   -fill white    -annotate 0 "text1" \) \
    \( -page +${hor_offset}+0 {im2}.png \
    -gravity south  -pointsize 14 \
    -stroke '#000C' -strokewidth 2 -annotate 0 "text2" \
    -stroke  none   -fill white    -annotate 0 "text2" \) \
    \( -page +0+${ver_offset} ${im3}.png \
    -stroke '#000C' -strokewidth 2 -annotate 0 "text3" \
    -stroke  none   -fill white    -annotate 0 "text3" \) \
    +page -flatten out.png

我之前有过更好的结果,但主要是偶然,决定寻求专家的帮助。

最终结果应该是这样的:Expected result

【问题讨论】:

    标签: imagemagick imagemagick-convert


    【解决方案1】:

    -page 不尊重-gravity。 -page 始终相对于图像的西北角(左上角)。您可以交替使用 -gravity 和 -geometry 与 -composite 成对使用。创建一张图像,然后在正确位置合成背景。重复该结果和要覆盖的另一个图像。见http://www.imagemagick.org/Usage/layers/#convert

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-05-08
      • 2019-03-14
      • 1970-01-01
      • 2015-08-08
      • 1970-01-01
      • 1970-01-01
      • 2020-11-12
      相关资源
      最近更新 更多