dongqing8765 2014-10-10 07:56
浏览 102
已采纳

ImageMagick - 如何设置水平中心位置和自定义垂直位置?

i have a problem with ImageMagick. Need to write dinamic text on image but also need to set center position as in CSS text-align:center and custom top position (ex. top:10px)

can you help me ?

Thanks

example enter image description here

  • 写回答

1条回答 默认 最新

  • dty47696 2014-10-10 12:10
    关注

    I think I would do it by creating and centering each word on its own transparent background and then compositing over the main background, something like this:

    #!/bin/bash
    STYLE="-pointsize 550 -stroke #FF0000 -fill #FFFFFF -font Times -gravity center"  # standardise parameters
    BASIC="-size 4000x600 xc:transparent"                                             # standardise parameters
    convert $BASIC $STYLE -draw "text 0,0 'ROBINETTE'" w1.png    # word 1 centred on transparent
    convert $BASIC $STYLE -draw "text 0,0 'FAMILY'"    w2.png    # word 2 centred on transparent
    convert $BASIC $STYLE -draw "text 0,0 'CHRISTMAS'" w3.png    # word 3 centred on transparent
    convert -define png:bit-depth=8 -size 4000x4000 xc:transparent w1.png -geometry +0+100 -composite w2.png -geometry +0+2800 -composite w3.png -geometry +0+3400 -composite out.png
    

    enter image description here

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换