【问题标题】:Imagemagick label issueImagemagick标签问题
【发布时间】:2012-02-26 00:47:29
【问题描述】:

我正在使用 imagemagick 6.2.8,我想在右侧对齐的图像底部添加一个标签。

这是我的代码:

convert image.png -gravity center -background "#f0f0f0" -font bgothm.ttf -pointsize 18 label:"text text" -append "append_image.png"

但是标签是靠左对齐的

如何将标签向右对齐?

编辑: 我发现了这一点:在 IM v6.4.7 之前,对齐附加图像要困难得多,并且通常涉及使用“-flop”进行右对齐。或者使用“-extent”或“-border”来调整居中对齐附加的图像宽度。 但我从来没有用过imagemagick

【问题讨论】:

    标签: imagemagick label gravity


    【解决方案1】:

    右下对齐,use -gravity southeast.

    convert image.png -gravity southeast -background "#f0f0f0" -font bgothm.ttf -pointsize 18 label:"text text" -append "append_image.png"
    

    【讨论】:

      【解决方案2】:

      编辑:我已更新我的解决方案以适用于您的 ImageMagick 版本。

      做双翻牌的把戏。一个 flop 来镜像文本,所以它会右对齐,一个 flop 来镜像 append 以使其可读:

      convert image.png -background "#f0f0f0" -font bgothm.ttf \
        -pointsize 18 label:"text text" -flop -append -flop "append_image.png"
      

      为我生成this 图像。请注意 -flop -append -flop do 的顺序很重要!

      不过,更好的解决方案是将 ImageMagick 升级到 >= 6.4.7 并使用 -gravity SouthEast:

      convert image.png -gravity SouthEast -background "#f0f0f0" -font bgothm.ttf \
        -pointsize 18 label:"text text" -append "append_image.png"
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2011-06-10
        • 2014-02-11
        • 2012-11-08
        • 2013-02-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多