I'm confused about how to combine two commands, I believe it's called piping.
I want to convert a tif to a png, and then use the converted png to composite.
convert tif.tif png.png
-then-
composite -compose Dst_Over -tile ~/checkerboard.gif png.png output.jpg
I'm just unclear about how to do this, or if this is something that can be done. Can commands be piped together, or is it one at a time?
I'd love a little explanation of the syntax, or just a point in the right direction for where to read about it.
Thnx!
Piping or One command and then another
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Piping or One command and then another
Piping is a facility from the operating system. In a nutshell, it sends the stdout from one command to the stdin of another. The commands generally use "-" as a placeholder for stdin or stdout, and the "|" character creates the pipe.
For example (Windows, but Unix may be the same):
This (pointless) example runs convert to create an image and send it to stdout. The OS then runs convert again, giving it an image in stdin. The second convert saves the image.
See documentation for your OS.
For example (Windows, but Unix may be the same):
Code: Select all
convert -size 50x50 xc:black miff:-|convert miff:- x.png
See documentation for your OS.
snibgo's IM pages: im.snibgo.com
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Piping or One command and then another
Why would you need to convert from tiff to png. Both should work fine. It seems a waste of time, unless you are going to store the png and use it later. But then there would be no need for piping.
Generally you can combine two commands into one command line by using convert ... -composite rather than composite and using parenthesis processing.
see
http://www.imagemagick.org/Usage/compose/#compose
http://www.imagemagick.org/Usage/basics/#parenthesis
composite is a rather old and limited command from early IM and is soon to be deprecated for IM 7. convert is much more flexible and it would benefit you to start using convert wherever you were using composite.
Generally you can combine two commands into one command line by using convert ... -composite rather than composite and using parenthesis processing.
see
http://www.imagemagick.org/Usage/compose/#compose
http://www.imagemagick.org/Usage/basics/#parenthesis
composite is a rather old and limited command from early IM and is soon to be deprecated for IM 7. convert is much more flexible and it would benefit you to start using convert wherever you were using composite.