Linux - A script to combine 2 images

April 2018

Wondering how to combine two pictures? There Gimp is perfect but it is also a lengthy process.
Here's a small script that will allow you to assemble two or more images (you can just change the script accordingly).

The code

echo  -n "give the name of the first image with the path "      
read image1     
echo  -n "give the name of the second image with the path"     
read image2     
echo  -n "name of file generated "     
read image3     
#echo -n " output size ex:800x600(will generate an image of 1600x600) "     
echo -n "Modify the size y/n "     
read modifiy     
case $modifiy in      
 montage  -geometry +1+1  $image1 $image2 $image3     
   gpicview $image3 &     
echo -n " output size ex:800x600(donnera 1600x600) "     
read taille     
echo -n " border y/n "     
read reponse      

case $reponse in     

 O|o )     



montage  -geometry $size1 $image1 $image2 $image3     

gpicview $image3 &     



Creating the script

  • Open your text editor (vim gedit kate etc..), Make a copy/paste the code, save it, for example, assemblephotos.
  • Open a terminal
  • Navigate to the directory where you saved assemblephotos, then type:
  • chmod +x assemblephotos what makes your script executable.
  • To run:
    • ./assemblephotos 
  • The program at the ends opens the picture in your image viewer.
  • In the script
    • gpicview 
  • You can put another, simply replace gpicview with your own.
  • To make life easier, run the script in the directory where the photos are.
  • You can embellish the script at will. For additional commands from the command editing:
  • $man mount
  • Required program

For Windows users:
  • You need to install imagemagick for Windows
  • Start>Run>cmd

The script should look like that:

Microsoft Windows XP [version 5.1.2600]   
(C) Copyright 1985-2001 Microsoft Corp.   

C:\Documents and Settings\jxxxx>cd C:\Documents and Settings\All Users\Documents\   
Mes images\Échantillons d'images   

C:\Documents and Settings\All Users\Documents\Mes images\Échantillons d'images>   
montage  -geometry +1+1 collines.jpg hiver.jpg total.jpg   

C:\Documents and Settings\All Users\Documents\Mes images\Échantillons d'images>   


Published by deri58. Latest update on December 15, 2010 at 10:06 AM by jak58.
This document, titled "Linux - A script to combine 2 images ," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (
Linux - Difference between /tmp and /var/tmp
Linux - Change the name of partitions