Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am sure there would be a simple command for this however I have not been able to find one.

Basically I would like to stitch a photo below another photo with no overlap. Also ideally I would like a command that can automate this process for 200 top images where the same bottom image is stitched. All images have the same width so no transformation is required.

I am looking for a program something like "stitch -below top.png bottom.png", I have explored options like Montage but can not seem to get it to work as required. Looking for advise.

share|improve this question
    
Um...What exactly you want to do want to do with this question? Could you please be a little more precise about what you want to do (eg...program name, etc.) –  RPi Awesomeness Mar 21 '13 at 20:53
    
@packpatfan, the question is clear for me. He is looking for a program to perform that task. –  guntbert Mar 21 '13 at 20:58
    
I suppose, but he could have been a bit more concise about stating that in his question. To me it appeared that he was looking for a plugin/command for an image editor (Unmentioned). –  RPi Awesomeness Mar 21 '13 at 20:59
    
I am looking for a program something like "stitch -below top.png bottom.png", I have explored options like Montage but can not seem to get it to work as required. Looking for advise. –  murphc05 Mar 21 '13 at 21:15
    
Please provide additional information only by editing your question and not within a comment. Comments might/will eventually be deleted and so your information would get lost. –  guntbert Mar 21 '13 at 21:16

1 Answer 1

up vote 3 down vote accepted

First you need to open a terminal and sudo apt-get install imagemagick.

Now place all your images in the same folder so you can easily access them from the terminal. Put the top images all in their own folder and keep the bottom image elsewhere to simplify things.

Type cd DIRNAME, you need to replace DIRNAME with the name of the folder the pictures are stored in, for example /home/mark/collating is what I use for this purpose.

Now that your shell is in the right folder and imagemagick is installed we use the following to stick the images together:

convert -append image1.jpg image2.jpg output.jpg

This will take the two images named image1 and image2 and stick image2 on the bottom of image1, saving the result as a file named output.jpg.

To automate this you can use a script like this one. You need to change the variables so they point to the right places.

#! /bin/bash

#   Replace the values of these variables with the locations of your tops and the bottom.
# The output directory must already exist!
#   "~/" is a shortcut for your home dir, FYI.

TopsDir="~/collating/tops" #Only the TOP images should be in this folder!
BottomImg="~/collating/bottom.png"
OutputDir="~/collating/complete"

[ -d "$TopsDir" -a -d "$OutputDir" ] && [ -f "$BottomImg" ] || { echo "One of the paths you supplied wasn't valid."; exit 1;}

cd "$TopsDir"

for TopImg in *; do
    convert -append "$TopImg" "$BottomImg" "$OutputDir/$TopImg"
done

Copy and paste it into gedit or your text editor and edit the variables so that they point to the correct folders. (Or file for the bottom img.) Save it as collator.sh. It is convenient for the next steps if you save it in your home directory.

Now open a terminal and navigate to where you saved the file. (You're already there if you saved it in your home dir, otherwise type cd /path/to/your/location) Type chmod +x collator.sh to give the file execute permissions.

And now we get the work done:
Type ./collator.sh to run the script; and you're done.

share|improve this answer
1  
To automate this, make a file filename.sh in DIRNAME, and write (something like) #!/bin/bash [NewLine] for FILE in ./*.jpg; do convert -append "${FILE}" bottom.png "${FILE}" [NewLine] done. Then mark the file as executable (right click > permissions) and run. This (I think) should do it for all files, but will overwrite the originals, so make a copy! (I don't know how to manipulate the second "${FILE}" to produce a new name -- "${FILE}2" gives filename.jpg2, else I got errors. I hope it will help anyways!) –  Rasmus Mar 21 '13 at 22:42
    
WOW I got it working Mark!!!! You guys have saved me days!! This is helpful beyond belief, I don't think I have ever been this happy with the internet! Thankyou Mark and Rasmus. –  murphc05 Mar 22 '13 at 6:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.