Page 1 of 1

Combine few operations in cmd

Posted: 2016-05-02T06:21:20-07:00
by venimus
Hello, I am trying to make two operations in cmd. Here is it:

Code: Select all

convert "c:\image1.png" -transparent white -resize 40% "c:\image1-1.png"
composite -gravity center "c:\image1-1.png" -geometry +120+100 "c:\Background.png" "c:\Overlay.png" "c:\Done.png"
Everything works fine. But how can I write these commands in one line? Without saving "c:\image1-1.png". And how to composite more than three images?

Re: Combine few operations in cmd

Posted: 2016-05-02T06:55:27-07:00
by snibgo
Use "convert" instead of "composite". Then the output of the first "convert" is one of the input to the second, so you can easily combine the two converts.

Re: Combine few operations in cmd

Posted: 2016-05-02T07:59:56-07:00
by venimus
Something like that?

Code: Select all

convert "c:\img1.bmp" -resize 200x400 -colorspace Gray -composite -geometry +100+100 "c:\Background.png" "c:\result.png"
But this saved only Bacjground image without "img1.bmp" on it.

Re: Combine few operations in cmd

Posted: 2016-05-02T08:25:04-07:00
by snibgo
"Composite" and "convert" need the names of the first two input images in the opposite order to each other.

"-composite" is an operation to the "convert" command. It must come after the images have been read.

Re: Combine few operations in cmd

Posted: 2016-05-02T08:34:24-07:00
by venimus
Can you show it in example of my code?

Here is what I am trying to do:

Code: Select all

convert "c:\image1.bmp" -resize 200x400 -colorspace Gray -geometry +100+50 "c:\result.png"
composite "c:\result.png" -geometry +50+100 "c:\image2.png" "c:\result.png")
composite "c:\image3.png" "c:\result.png" "c:\result.png"
convert "c:\image4.png" -transparent white -resize 10% "c:\image4.png"
composite "c:\image4.png" -geometry +100+200 "c:\result.png" "c:\result.png"
composite "c:\image5.png" "c:\result.png" "c:\result.png"
And I'm getting everything I need. But is there another way instead of running each line in cmd. Maybe some faster way with one line code?

Re: Combine few operations in cmd

Posted: 2016-05-02T10:41:20-07:00
by fmw42
See parenthesis processing, convert ... -composite. Use the convert ... -composite syntax so that you can put it all in one command line.

http://www.imagemagick.org/Usage/compose/#compose
http://www.imagemagick.org/Usage/basics/#parenthesis
http://www.imagemagick.org/Usage/layers/#convert

see similar discussion at viewtopic.php?f=1&t=29581
composite "c:\result.png" -geometry +50+100 "c:\image2.png" "c:\result.png")
Why is there a parenthesis at the end, here?
convert "c:\image1.bmp" -resize 200x400 -colorspace Gray -geometry +100+50 "c:\result.png"
Why is there -geometry +100+50? Is is a setting with no operator? What are you trying to do with that?

Perhaps if you post your input images and final output image, we could combine your commands for you.

Try this:

Code: Select all

convert "c:\image2.png" ^
( "c:\image1.bmp" -colorspace Gray -resize 200x400 ) ^
-geometry +50+100 -compose over -composite ^
"c:\image3.png" -compose over -composite ^
( c:\image4.png" -transparent white -resize 10% ) ^
-geometry +100+200 -compose over -composite ^
"c:\image5.png" -compose over -composite "c:\result.png"

Re: Combine few operations in cmd

Posted: 2016-05-03T06:07:35-07:00
by venimus
Thank you! This exactly what I needed =)