ImageMagick 和管道

Jim*_*ath 4 bash pipe imagemagick 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
Run Code Online (Sandbox Code Playgroud)

我正在创建两个图像,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
Run Code Online (Sandbox Code Playgroud)

Sea*_*ght 5

这是完全未经测试的,因此请确保在测试前备份相关图像:

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
Run Code Online (Sandbox Code Playgroud)

(这称为“进程替换”)