Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
venimus
Posts: 4 Joined: 2016-05-02T06:13:04-07:00
Authentication code: 1151
Post
by venimus » 2016-05-02T06:21:20-07:00
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?
snibgo
Posts: 12159 Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Post
by snibgo » 2016-05-02T06:55:27-07:00
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.
venimus
Posts: 4 Joined: 2016-05-02T06:13:04-07:00
Authentication code: 1151
Post
by venimus » 2016-05-02T07:59:56-07:00
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.
snibgo
Posts: 12159 Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK
Post
by snibgo » 2016-05-02T08:25:04-07:00
"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.
venimus
Posts: 4 Joined: 2016-05-02T06:13:04-07:00
Authentication code: 1151
Post
by venimus » 2016-05-02T08:34:24-07:00
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?
fmw42
Posts: 25562 Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA
Post
by fmw42 » 2016-05-02T10:41:20-07:00
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"
venimus
Posts: 4 Joined: 2016-05-02T06:13:04-07:00
Authentication code: 1151
Post
by venimus » 2016-05-03T06:07:35-07:00
Thank you! This exactly what I needed =)