views:

213

answers:

1

I have the following commands that create a sprite containing a normal state and a hover state:

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

I'm creating two images, top.png and bottom.png then combining them to create test.png.

Is there a way to do this without having to write the top and bottom images to disc?

Can I pipe the commands together some how?

Update: Solution

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
+2  A: 

This is completely untested, so make sure to backup the relevant images before testing:

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

(This is called "Process Substitution")

Sean Bright
After a bit of tinkering, I managed to get this to work: 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 The original code you posted still wrote the images to disc, but this seems to work.Hoorah!
JimNeath
Excellent. I've updated my answer accordingly.
Sean Bright