Sample Header Ad - 728x90

I need to create a loop in bash to join images vertically and ouput multiple joined Pages for print

2 votes
4 answers
1780 views
**I am running Ubuntu 18.04.** I have a directory full of storyboard images in .jpg format as below. image-0000.jpg image-0001.jpg image-0002.jpg image-0003.jpg image-0004.jpg . . image-3898.jpg image-3899.jpg **Merging 13 images vertically gives me a Single page.** So I think I need to use below command, using a range of 13 numbers at a time in a loop and save to a directory "./Merged". convert -append image-{range of 13}.jpg ./Merged/page_001.jpg > **My experiment and thought process is as below.** I am trying to use a nested for loop and seq -w as below. But I am unable understand, how to loop the scrip in such a way that it takes first 13 files (from image-0000 to image-0012), merges them and saves in the ./Merged/ folder. Then come out of the loop and again take the next 13 files (from image-0013 to image-0025) and so on. Till all .jpg files in the current folder are finished or till 300 pages are generated. **My Script** #!/bin/bash # As 3899 image slices will be converted to 300 pages # I thought to run for loop 300 times for ((page=1; page<=300; page++)) do # As images are slices of pages. for slices in $(seq -w 0 3899) do # We need to merge 13 times so... # Should i use for loop with increment as below? # for ((smerge=1; smerge<=13; smerge++)) # do # convert "SOME LOGIC" ./Merged/page_001.jpg # done # **OR** # somehow take 13 numbers from sequence convert image-$slices_{RANGE}.jpg -append ./Merged/page_$page.jpg done done
Asked by user3025253 (23 rep)
Jun 12, 2018, 10:49 PM
Last activity: Apr 30, 2022, 08:00 PM