Page 1 of 1

how do I put 2 pictures together?

Posted: 2018-12-02T08:30:14-07:00
by metalbear
Hello everybody!
I need help to put two pictures together in a batch processing unit.
The files have the same name and are stored in different directories.
The picture in directory A is 3600x2400 pixel
The picture in directory B is 1683x1274 pixel
The image in directory B should be placed on the image in directory A, with the upper left corner on pixel X: 638 and Y: 584.
And the whole as a batch for over 500 files, consecutively numbered.
I work in a windows environment.
Can someone write me the appropriate command line?
Thank you very much!

Re: how do I put 2 pictures together?

Posted: 2018-12-02T09:12:11-07:00
by metalbear
Alternatively, the images in directory B could be available in the same size as directory A, but only a specific section of image B should be inserted.

Re: how do I put 2 pictures together?

Posted: 2018-12-02T09:39:56-07:00
by snibgo
What version of IM? I'll assume v7.

First steps first, which is the image processing. You want to composite one image over another, at a certain offset. Worry about the loop later.

Code: Select all

magick imageB.png imageA.png -geometry +638+584 -composite out.png
Does that do what you want?

For your extra question, you might need a test on whether the imageB is the same size as imageA, then do:

Code: Select all

magick ( imageB.png -crop {something} +repage ) imageA.png -geometry +638+584 -composite out.png

Re: how do I put 2 pictures together?

Posted: 2018-12-02T10:34:14-07:00
by metalbear
Thank you very much for your answer.
Your first code does exactly what I need.

Can you also tell me how to build a loop?

Re: how do I put 2 pictures together?

Posted: 2018-12-02T11:45:45-07:00
by snibgo
I would use a "for" loop, like this:

Code: Select all

for /F %F in (directoryA\*) do magick directoryB\%F directoryA\%%F -geometry +638+584 -composite outdir\%F
For help on "for", type "for /?".

If using in a BAT script, double the percentage signs.

Re: how do I put 2 pictures together?

Posted: 2018-12-02T12:52:40-07:00
by metalbear
Good evening.
Thanks again for your answers.
I use Windows10 as OS, magick-version = 7.0.8-15

I tried your for-loop in a BAT script, ends in error file cant be found.

Code: Select all

for /F %%F in (.\GreenScreen\umbenannt\*) do magick .\GreenScreen\umbenannt\%%F .\Originals_klein\Ausschnitt\umbenannt\%%F -geometry +638+584 -composite .\NEU\%%F
Die Datei ".\GreenScreen\umbenannt\*" kann nicht gefunden werden.
I tried to google it, this happens because /F cant be used with a wildcard.

Then i tried without /F :
D:\Bilder\2018\Hochzeit_dslrbooth>magick .\GreenScreen\umbenannt\.\GreenScreen\umbenannt\515.jpg .\Originals_klein\Ausschnitt\umbenannt\.\GreenScreen\umbenannt\515.jpg -geometry +638+584 -composite .\NEU\.\GreenScreen\umbenannt\515.jpg
magick: unable to open image '.\GreenScreen\umbenannt\.\GreenScreen\umbenannt\515.jpg': No such file or directory @ error/blob.c/OpenBlob/3490.
ThereĀ“s a problem with %F, it shows always the full directory, not only the filename.

Re: how do I put 2 pictures together?

Posted: 2018-12-02T13:02:21-07:00
by snibgo
Sorry, yes, remove "/F", and use "%~nxF".

Re: how do I put 2 pictures together?

Posted: 2018-12-03T11:39:12-07:00
by metalbear
Thats it! Thank you very much for your great support!