ImageMagick和管道

时间:2009-07-21 14:00:39

标签: bash imagemagick pipe montage

我有以下命令创建一个包含正常状态和悬停状态的精灵:

convert -background none -pointsize 11 -fill white -size 100x -gravity NorthWest caption:'Test' top.png
convert -background none -pointsize 11 -fill grey -size 100x -gravity SouthWest caption:'Test' bottom.png
montage top.png bottom.png -geometry +0+0 -tile 1x2 -background none test.png

我正在创建两个图像,top.png和bottom.png,然后将它们组合起来创建test.png。

有没有办法在不必将顶部和底部图像写入光盘的情况下执行此操作?

我可以将命令汇总到一起吗?

更新:解决方案

montage \
  <(convert -background none -pointsize 11 -fill white -size 100x -gravity NorthWest caption:'Test' png:-) \
  <(convert -background none -pointsize 11 -fill grey -size 100x -gravity SouthWest caption:'Test' png:-) \
  -geometry +0+0 -tile 1x2 -background none test.png

1 个答案:

答案 0 :(得分:4)

完全未经测试,因此请务必在测试前备份相关图片:

montage \
  <(convert -background none -pointsize 11 -fill white -size 100x -gravity NorthWest caption:'Test' png:-) \
  <(convert -background none -pointsize 11 -fill grey -size 100x -gravity SouthWest caption:'Test' png:-) \
  -geometry +0+0 -tile 1x2 -background none test.png

(这称为“Process Substitution”)