automatically append jpg files

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
MS86
Posts: 2
Joined: 2017-12-18T06:44:31-07:00
Authentication code: 1152

automatically append jpg files

Post by MS86 » 2017-12-18T07:11:39-07:00

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.

User avatar
fmw42
Posts: 22449
Joined: 2007-07-02T17:14:51-07:00
Location: Sunnyvale, California, USA

Re: automatically append jpg files

Post by fmw42 » 2017-12-18T10:41:17-07:00

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.

MS86
Posts: 2
Joined: 2017-12-18T06:44:31-07:00
Authentication code: 1152

Re: automatically append jpg files

Post by MS86 » 2017-12-18T12:47:01-07:00

:D :D Great, it did the trick. Thank you very much!

Post Reply