How to Combine Multiple Images Quickly

If you have ever started an eBay auction and wanted to add your large picture collection to it, you will quickly realize that you can only add up to 12 pictures.  While it is true pictures can be added to the body of the auction and linked to an alternate sources, that is extra work. As a work-a-round to the 12 picture limit, pictures can be combined together.  Originally, I used Windows GUI based applications to organize my photos and combine them, but after spending about 45 minutes to an hour sorting through 30+ pictures only to realize that I would have to repeat this process for additional auctions, I had to come up with a solution.  One, that will take 45 minutes to less than 5 seconds using CentOS Linux!

Below is what an eBay seller is presented while setting up an eBay auction.


In this example, suppose you have 33 images that you freshly scanned onto your Windows box. Once scanned, I copied the whole lot over to the Linux box.

ls -1 scan*.jpg

The truncated result.


I can go through all my iterations to get to this point, but I’ll spare you the boring details. The prerequisites.

yum -y install ImageMagick

Also a script that I found and is listed in the source(s) below.  I was unable to incorporate the script called into one script so I use base64 to decode into a new file a Not necessary, this could be a file added to the Linux box, but this is how I wanted this work.

Here are the goals of this script.

  • User define the variable, fbase to prefix your final pics.
  • Create the script, to pad the number from 1 to 01, 2 to 02 through to 09 to better sort the pics.
  • Resize the pics into manageable sizes.
  • Combine the individual pics into groups of 3 horizontally aligned as used by the “-tile 3×1”
  • Create a montage of all the pictures for the main eBay pic.
  • Renumber the pics.


##### contents of ################
##num=`expr match "$1" '[^0-9]*\([0-9]\+\).*'`
##paddednum=`printf "%02d" $num`
##echo ${1/$num/$paddednum}

base64 -d << EOF >

chmod +x

#Resize all scans
for i in scan0*.jpg; do convert $i -resize 534 $(basename $i .jpg).jpg; done
# Use this one if the images are slightly different in size.
#for i in scan0*.jpg; do convert $i -resize "534x534^" -gravity center -crop 534x534+0+0 +repage $(basename $i .jpg).jpg; done
#Combine 3 images into 1
montage scan0*.jpg -tile 3x1 -geometry +0+0 $fbase.jpg
#Creates a large montage
montage scan0*.jpg -tile 6x5 -geometry +0+0 $fbase-all.jpg
#run with zeropad
for i in $fbase-*.jpg;do mv $i `./ $i`; done


Here are three source pictures (scan0186.jpg,scan0187.jpg, and scan0188.jpg), already resized.  Using the script above, these images are combined into the one picture below.


Below, is a combined image called, ebaypics-01.jpg, resized and ready to go.


Hope that this helps someone else.

Here is a partial screenshot of an actual eBay auction, complete with the “master picture” and the groups of three.