I have two images of identical size that I want to programmatically crop, move and merge using a bash script in OSx El Capitan, preferably using something like ImageMagick.
The images are equal size, and I want to create a resulting image of the same size. In the resulting image, I want the first image (1
) to be moved 25% of it's width to the left, while the second image (2
) is moved 25% of it's width to the right. 1
should then be cropped 25% from it's right edge and placed on top of 2
.
To explain it in a more graphical way, here are my two original images:
The entire operation looks something like this, where the red frame represents the resulting image boundary, and the yellow frame represents the part of 1
that should be cropped away.
The resulting image should look like this:
How would I accomplish something like this in a bash script in OSx? I read a guide on ImageMagick layers, but when I try to run my bash script (which uses a MIFF:-
stream to join the layers) I just get the output (at least that's what I think it is) in the terminal instead of as a new file.
If someone can help me get started (or if you're up to it provide a working example) I'd be grateful.
So, if I start with this as image 1 (400x300px):
and this as image 2 (400x300px):
I think you want this (400x300px):
convert \( 1.png -gravity center -crop 50x100% \) \
\( 2.png -gravity west -crop 50x100% \) +append result.png