2009-07-21 43 views
3

我有一個創建一個包含正常狀態和懸停狀態的sprite以下命令:ImageMagick的和管道

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 

回答

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」)

+0

經過一番修補之後,我設法讓這個工作: 蒙太奇\ <(convert -background none -pointsize 11 -fill white -size 100x -gravity NorthWest標題:'測試'png :-) \ <(convert -background none -pointsize 11 -fill gray -size 100x - 重力西南字幕:'Test'png :-) \ -geometry + 0 + 0 -tile 1x2 -background none test.png 您發佈的原始代碼仍然將圖片寫入光盤,但這似乎起作用。 Hoorah! – 2009-07-21 14:42:58