【问题标题】:ImageMagick background image?ImageMagick 背景图片?
【发布时间】:2012-04-20 05:50:33
【问题描述】:

我最近才开始探索 ImageMagick,但我有一个疑问。我一直在寻找,但找不到解决方案。

使用以下代码:

convert -background lightblue  -fill blue  -font Candice -pointsize 30 \
          -size 220x220  -gravity Center  caption:'$txt' \
          $name.gif

如何使用图像作为背景而不是静态颜色?

我尝试了-background "file.jpg",但它不起作用。

【问题讨论】:

    标签: imagemagick


    【解决方案1】:

    使用-texture 而不是-background

    【讨论】:

    • 我尝试用 -texture 'file.jpg' 替换 -background 'file.jpg' 但它带有白色背景
    【解决方案2】:

    我想我误解了你最初的问题。这会将图像平铺到设定大小的背景上并添加一些文本。

    $txt = 'Caption';
    // Tile the image - no background as it will not be seen behind the tile
    $cmd = " -size 220x220 tile:noise.jpg -font Candice -fill blue -pointsize 30 ".
    "-gravity Center -annotate +0+0 $txt";  
    exec("convert $cmd output.jpg");
    

    【讨论】:

    • 在 OS X 的 shell 中使用 ImageMagick 时,您必须指定字体的完整路径。convert -size 220x220 tile:/Applications/Chess.app/Contents/Resources/selected_piece_texture.png -fill blue -font /Library/Fonts/Arial\ Narrow.ttf -pointsize 30 -gravity Center -annotate +0+0 "some text" output.png
    【解决方案3】:

    根据您所追求的效果,有很多方法,但这是一种简单的方法:

    转换 input.jpg -fill blue -font Candice -pointsize 30 -gravity Center -annotate +0+0 "Some text" $name.gif

    我无法理解这个网站发布代码的方式:(

    【讨论】:

      猜你喜欢
      • 2018-03-10
      • 1970-01-01
      • 2017-03-14
      • 2013-08-16
      • 1970-01-01
      • 2019-03-24
      • 1970-01-01
      • 1970-01-01
      • 2018-10-11
      相关资源
      最近更新 更多