combine serveral commands

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?".
Post Reply
Adrian
Posts: 1
Joined: 2016-10-25T04:27:09-07:00
Authentication code: 1151

combine serveral commands

Post by Adrian » 2016-10-25T04:35:07-07:00

Hi everyone,
I want to combine serveral commands to create one Image to get the rigth output I have to compose different images and colorize them In a specific order, I have image a, b, c, d and e and I want to create one image like that:

a.png b.png -composite -gravity center -channel RGB -evaluate multiply 0.9 step1.png

c.png d.png -composite -gravity center -channel RGB -evaluate multiply 0.9 step2.png

step1.png step2.png e.png -composite -gravity center result.png

but in one command like that

((a.png b.png -composite -gravity center -channel RGB -evaluate multiply 0.9) (c.png d.png -composite -gravity center -channel RGB -evaluate multiply 0.9) -composite -gravity center) e.png -composite -gravity center result.png

but with brackets it doesn't work. Is there a way to archieve this or is there another strategy for Example Layers which can be adjust for this purpose?

tom_dl
Posts: 43
Joined: 2015-02-26T08:25:44-07:00
Authentication code: 6789

Re: combine serveral commands

Post by tom_dl » 2016-10-25T05:18:13-07:00

You can load all inputs at the begining like this:

Code: Select all

convert a.png b.png c.png d.png e.png
From now on, these have index numbers 0,1,2,3 respectively. When you want to work on them in parentheses you need to clone the indexes you want to work on. Like this:

Code: Select all

convert a.png b.png c.png d.png e.png \( -clone 0,1 -composite -gravity center -channel RGB -evaluate multiply 0.9 \)
From now on, the output of what we did in those parentheses has index number 5. If you do some more work in parentheses the output from those can be referenced by index numbers 6,7,8...
At the end when you want to output something you can delete all unecessary images in the sequence by using:

Code: Select all

-delete 0,2,3
(or whatever indexes you want to delete)
Let us know how that goes for you
Last edited by tom_dl on 2016-10-25T06:26:54-07:00, edited 1 time in total.

tom_dl
Posts: 43
Joined: 2015-02-26T08:25:44-07:00
Authentication code: 6789

Re: combine serveral commands

Post by tom_dl » 2016-10-25T05:31:56-07:00

Code: Select all

convert a.png b.png c.png d.png e.png \
\( -clone 0,1 -composite -gravity center -channel RGB -evaluate multiply 0.9 \) \
\( -clone 2,3 -composite -gravity center -channel RGB -evaluate multiply 0.9 \) \
\( -clone 5,6,4 -composite -gravity center \) \
-delete 0-6 output.png
Should work. I haven't tested it and I'm not sure what you're trying to achieve, but the cloning and deleting of indexes is the important part for you.

User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: combine serveral commands

Post by GeeMack » 2016-10-25T06:54:36-07:00

Adrian wrote:Hi everyone,
I want to combine serveral commands to create one Image to get the rigth output I have to compose different images and colorize them In a specific order, I have image a, b, c, d and e and I want to create one image like that:
Two things I notice about your example. First, you need to put the "-gravity" setting before of the "-composite" where you want it to apply. And second, you still have three images going into the last operation, but "-composite" is only going to work on two of them. You'll have to do that in steps or you'll have to assemble them using "-layers ...".

What tom_dl explained for using parenthesis should help you combine all that into a single command, but you really need to let us know which version of ImageMagick you're using and what platform or shell you're running the command on. Show us complete examples of your commands, and maybe link to some sample images of your input and desired output.

tom_dl
Posts: 43
Joined: 2015-02-26T08:25:44-07:00
Authentication code: 6789

Re: combine serveral commands

Post by tom_dl » 2016-10-25T08:01:26-07:00

Thanks GeeMack - I hadn't checked the rest of the code. Do note that -composite can take three images if the third is a mask.

User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: combine serveral commands

Post by GeeMack » 2016-10-25T09:10:14-07:00

tom_dl wrote:Do note that -composite can take three images if the third is a mask.
Yep. I was picturing a series of simple overlay composites, but yes, that is correct. There are situations where a third image is used in a "-composite".

snibgo
Posts: 12163
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: combine serveral commands

Post by snibgo » 2016-10-25T11:09:02-07:00

To add to the comments made by others: every "-channel" should have a "+channel", so they bracket the operation(s) that apply to only certain channels. It may not matter in this particular case, but I think it's bad practice to omit "+channel".
snibgo's IM pages: im.snibgo.com

Post Reply