Merging batch images side by side

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
diego182
Posts: 4
Joined: 2013-09-09T12:13:28-07:00
Authentication code: 6789

Merging batch images side by side

Post by diego182 »

hi all
I'm trying to merge a set of images from two ip cameras, to get as a result sort of a panorama, and merge one of this is really easy. Then I tried to merge a batch of them, to execute the script once a day and thats where i'm getting stuck at, i'm gonna paste here the code i have so far.

Code: Select all

REM @ECHO OFF

REM @ECHO OFF
set DATA=%DATE%
set DAY=%DATA:~0,2%
set MONTH=%DATA:~3,2%
set YEAR=%DATA:~6,4%
set FOLDERNAME=%YEAR%%MONTH%%DAY%
set FILENAME=Hangar_1-%YEAR%-%MONTH%-%DAY%*.jpg
"C:\Program Files (x86)\ImageMagick-6.8.6-Q16\convert.exe" "C:\Users\modClima\Desktop\teste video\Camera Hangar ModClima 1\grabs\Hangar_1-2013-09-09_11-32-14_418.jpg" "C:\Users\modClima\Desktop\teste video\Camera Hangar ModClima 2\grabs\Hangar_2-2013-09-09_11-32-15_458.jpg" +append "C:\Users\modClima\Desktop\resultado teste\%FOLDERNAME%\teste1.jpg"

EXIT
and the thing i've tried to do so far was put an asterisk on the file name, like the example below, and the result was that it did try to merge all the images at once.

Code: Select all

"C:\Program Files (x86)\ImageMagick-6.8.6-Q16\convert.exe" "C:\Users\modClima\Desktop\teste video\Camera Hangar ModClima 1\grabs\Hangar_1-2013-09-09*.jpg" "C:\Users\modClima\Desktop\teste video\Camera Hangar ModClima 2\grabs\Hangar_2-2013-09-09*.jpg" +append "C:\Users\modClima\Desktop\resultado teste\%FOLDERNAME%\teste1.jpg"
and the other alternative i did was a loop, but the .bat didn't even executed

Code: Select all

for file in *.jpg; "C:\Program Files (x86)\ImageMagick-6.8.6-Q16\convert.exe" "C:\Users\modClima\Desktop\teste video\Camera Hangar ModClima 1\grabs\Hangar_1-2013-09-09*.jpg" "C:\Users\modClima\Desktop\teste video\Camera Hangar ModClima 2\grabs\Hangar_2-2013-09-09*.jpg" +append "C:\Users\modClima\Desktop\resultado teste\%FOLDERNAME%\teste1.jpg"
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Merging batch images side by side

Post by snibgo »

Your FOR syntax is wrong for DOS batch files. Type "help for" for the correct syntax.
snibgo's IM pages: im.snibgo.com
diego182
Posts: 4
Joined: 2013-09-09T12:13:28-07:00
Authentication code: 6789

Re: Merging batch images side by side

Post by diego182 »

i've noticied now the syntax error, yet I really haven't figure out how to make this work, any help?

I believe that the right way would be something like this:

Code: Select all

FOR file IN *.jpg DO "C:\Program Files (x86)\ImageMagick-6.8.6-Q16\convert.exe" "C:\Users\modClima\Desktop\teste video\Camera Hangar ModClima 1\grabs\Hangar_1-2013-09-09*.jpg" "C:\Users\modClima\Desktop\teste video\Camera Hangar ModClima 2\grabs\Hangar_2-2013-09-09*.jpg" +append "C:\Users\modClima\Desktop\resultado teste\%FOLDERNAME%\teste1.jpg"
where file would be some variable, but i have no idea
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Merging batch images side by side

Post by snibgo »

Either you are very confused, or I am.

I think you have a bunch of frames in one directory, and another bunch in another directory. The same number in each, I hope. You want to "+append" them together.

Do the corresponding files have the same name in each directory?

You can do this by looping through the files in either directory (but NOT the files in your current working directory). Your "convert" command is okay, but it needs to be given the full filenames, without wildcards. Instead, you need to use the filename from the FOR variable.

The syntax of the FOR command is still wrong. Case doesn't matter (FOR or for).

See viewtopic.php?f=1&t=23891 which is an almost identical requirement.
snibgo's IM pages: im.snibgo.com
diego182
Posts: 4
Joined: 2013-09-09T12:13:28-07:00
Authentication code: 6789

Re: Merging batch images side by side

Post by diego182 »

u got it right, the problem is, the files do not have same name, the names are the time the frame was shoot, they have some milliseconds of difference some times even a second
i don't know if i can generate an array with the files, i think it would some how help me, i also did try do do the same thing using php CLI but got no success.

the question is,if the files have had a sequential file name would it be easier?

about the "for" commando i did change what i understand from "help FOR";
diego182
Posts: 4
Joined: 2013-09-09T12:13:28-07:00
Authentication code: 6789

Re: Merging batch images side by side

Post by diego182 »

Hi, i ended up doing it with php, and solve the problem, i've never done something with batch before, thanks for the help anyway.
Post Reply