Quantcast
Channel: geekoverdose
Viewing all articles
Browse latest Browse all 70

Animated gif creation with automatic image alignment

$
0
0
Animated gif created with align_image_stack and convert.

Animated gif created with align_image_stack and convert.

In case you took some photos showing a scene in motion, you probably want to create an animated gif out of them. If you did not use a tripod for fixing your camera, the images will not be aligned perfectly, so that the scene is slightly shifted within the images – which is clearly visible in the animated gif, and doesn’t look too good. I’ve stumbled across this problem recently: there exist several GUI based tools for Linux to do the image alignment and gif creation (such as with using this Gimp plugin), but at least the tools I’ve tried require the user to start much of the processing by hand – which simply eats up too much of my time.  Inspired from here I used a combination of align_image_stack (a part of the Hugin panorama tool set I’ve used in automatic panorama creation) and ImageMagick’s convert to automatically align images and create an animated gif from them to save me some time.

Aligning images

At first we need to align all images with the scene, so that they overlap “perfectly”. In this context, perfectly means adequate for my personal usage in animated gifs, as there are still minor shifts left after aligning. align_image_stack from the Hugin panorama tool suite is designed to do exactly that for aligning HDR images. Therefore, you can use

convert *JPG -resize 1000 +repage resized.jpg
align_image_stack -a aligned_ -C resized*

to a) copy and resize all *JPG images in the current directory (accelerates consecutive aligning) and b) automatically align all these files. “-a aligned” stands for the command producing .tif files which have this additional prefix, and “-C” stands for the command automatically cropping all images to those areas contained in all images.

Creating the animated gif

Now we can create an animated gif from the aligned images. ImageMagick’s convert provides all features you need in order to create the gif exactly as you’d like to have it. I personally used the following command to additionally rotate and resize the images and reduce the amount of used colors.

convert -format jpg -rotate "-90" -resize 600 +repage -delay 50 -loop 0 -colors 40 aligned_* animation.gif

That’s it, you’ve just created your aligned and animated gif.

Installation on Ubuntu 12.04

As align_image_stack comes with Hugin, and convert with ImageMagick, you just need to install those two tool suits from the Ubuntu repositories:

sudo apt-get install hugin imagemagick


Viewing all articles
Browse latest Browse all 70

Trending Articles