Page 1 of 1

automatically append jpg files

Posted: 2017-12-18T07:11:39-07:00
by MS86
Hello,
I have a bit of a problem I am not able to tackle using shell commands on Linux (IM Version 6.8.9-9 016 x86 64).

I have to download several book pages from a server where they are each split into 6 jpgs (3x2 cells per page). I downloaded them, naming each cell per page 1a.jpg, 1b.jpg, ... 1f.jpg, 2a.jpg ... 2f.jpg etc. until 50a.jpg ... 50e.jpg.

Now I want to append these cells to have a single jpeg for each page.

I can do this for one page by using

Code: Select all

convert \( 1a.jpg 1b.jpg 1c.jpg +append \) \( 1d.jpg 1e.jpg 1f.jpg +append \) -append 1.jpg
However, I am not able to do this automatically for all 50 pages (input 1a-e.jpg to 50a-e.jpg output 1.jpg to 50.jpg). I don't really get how to set up the variables for the file names correctly.

Any help would be very much appreciated.

Re: automatically append jpg files

Posted: 2017-12-18T10:41:17-07:00
by fmw42
try this

cd to directory holding the images

Code: Select all

list=`ls *.jpg`
for ((i=1; i<=50;i++)); do
convert \( ${i}a.jpg ${i}b.jpg ${i}c.jpg +append \) \( ${i}d.jpg ${i}e.jpg ${i}f.jpg +append \) -append ${i}.jpg
done
This should produce 1.jpg ... 50.jpg images.

Re: automatically append jpg files

Posted: 2017-12-18T12:47:01-07:00
by MS86
:D :D Great, it did the trick. Thank you very much!