Hello. I am trying to use this wonderful tool and I have succeeded in doing what I need, but slowly. Working in MAC OSX, I need to combine pairs of pics within a folder; they are named (something)_001.jpg and (something)_002.jpg. I merge them by using convert +append or -append, but this is slow, working with only two at the time. Is there any way to issue a command within the folder that does it automatically?. I tried : convert +append *_001.jpg *_002jpg *.jpg, but it does not work.
Any help would be appreciated. Thanks.
Combining many pairs of pics within a folder
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Combining many pairs of pics within a folder
Are "something" only in pairs. That is do you have XXX_001.jpg XXX_002.jpg and no other XXX_?
Please provide your IM version.
Can you provide a (partial) list of filenames in your folder, so we can see how they are listed in sequence.
You will likely have to write a bash script loop over the files in your directory and combine them in pairs. But you could do that by simply combining each successive pair or you might have to search for each pair of "something" names.
Please provide your IM version.
Can you provide a (partial) list of filenames in your folder, so we can see how they are listed in sequence.
You will likely have to write a bash script loop over the files in your directory and combine them in pairs. But you could do that by simply combining each successive pair or you might have to search for each pair of "something" names.
Re: Combining many pairs of pics within a folder
Something like:
2017_07_15_19_25_22_001.jpg
2017_07_15_19_25_22_002.jpg
2017_07_15_19_25_25_001.jpg
2017_07_15_19_25_25_002.jpg
...
And so on. Yes, I think the simplest would be to just combine each successive pair, because the numbers in the filenames change (those are just scan times).
2017_07_15_19_25_22_001.jpg
2017_07_15_19_25_22_002.jpg
2017_07_15_19_25_25_001.jpg
2017_07_15_19_25_25_002.jpg
...
And so on. Yes, I think the simplest would be to just combine each successive pair, because the numbers in the filenames change (those are just scan times).
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Combining many pairs of pics within a folder
If you have no skips, then you could do something like the following. Lets call your image directory, test. Create a new directory at the same level to hold your output images, if you want. Then do the following script, which you can copy and past into a terminal window. First change directories to your test directory.
Code: Select all
cd path2/test
arr=(`ls *.jpg`)
num=${#arr[*]}
for ((i=0; i<num; i=i+2)); do
j=$((i+1))
img1=${arr[$i]}
img2=${arr[$j]}
name=${img1%_001.jpg}
convert $img1 $img2 +append ../test2/${name}_001_002.jpg
done
Re: Combining many pairs of pics within a folder
I am speechless. It just works.
Thankyou. Thankyou. Thankyou. Thankyou. Thankyou.
Thankyou. Thankyou. Thankyou. Thankyou. Thankyou.
- GeeMack
- Posts: 718
- Joined: 2015-12-01T22:09:46-07:00
- Authentication code: 1151
- Location: Central Illinois, USA
Re: Combining many pairs of pics within a folder
There are several ways to accomplish this, but the best approach for your needs would depend on several factors. If the mated images are the same sizes, if all the images in the directory can fit in the memory you have available, and if you're using IM 7 it could be this simple...
Code: Select all
magick *_001.jpg -extent %[fx:s.w*2] null: *_002.jpg -gravity east -layers composite _%03d_out.png
Edited to add: Using IM6 on a *nix system this command would accomplish pretty much exactly the same thing...
Code: Select all
convert *_001.jpg -set option:distort:viewport %[fx:s.w*2]x%[fx:s.h] \
-distort SRT 0 null: *_002.jpg -gravity east -layers composite _out_%03d.png
Re: Combining many pairs of pics within a folder
It also works. Now I have two different ways of doing it. Thanks for all the help. Amazing site, great software and VERY helpful people here!!.