NewUser
NewUser

Reputation: 13333

Compose two images in shellscript

Hello Friends I am trying to compose two images in imagemagick shell script commane but getting some problem here. My problem is this I have two folders. In first folder let call it A and the second one let call it as B. In both A and B folder there are some images with the same name just like in folder A there is an image named as 'a' and the same named folder is in B folder. Now I want to make them compose with this command

composite -compose over -geometry +125+25 -background white
a.png a.png output.png

In this command image of A folder named as 'a.png' will be compose with B folders 'b.png' and the output will be 'output.png'.Now I can do this manually just one by one by running the command in terminal. I want the shell script of this one by which I can make compose large number of files.Any help and suggestions will be highly appreciable.

Upvotes: 1

Views: 121

Answers (1)

themel
themel

Reputation: 8895

I'm going to assume you meant

composite -compose over -geometry +125+25 -background white A/a.png B/a.png output.png

and that you want to put your results into a directory named out.

in the following:

for afile in A/* ; do
  base=$(basename "$afile")
  composite -compose over -geometry +125+25 -background white "A/$base" "B/$base" "out/$base"
done

The two basic features used here are command substitution and the basename command that returns just the file name part of a path.

Upvotes: 1

Related Questions