If you have hundreds of photos or images that you want to display in quick succession, create a video file using these steps on Linux. The result is slightly lossy, which means that there will be some pixilation, but the resulting file is much smaller than if you were to create an animated GIF. A rule of thumb is that 1000 photos will make a 640x480-pixel AVI file of 4.4MB in size and an 8MB-sized Flash video (.flv) file. Here's how to do it, using some fine open source technology in the form of the LIBAV library:
Step 1: Set up your Tool Chain
Install LIBAV if it is not already installed, as you will need the avconv utility. Note that the LIBAV replaces the legacy FFMPEG library. Read more about it here.
- On Sabayon:
$ sudo equo install libav
- On Gentoo:
$ sudo emerge libav
- On Mint and Ubuntu:
$ sudo apt-get install libav
- On Red Hat and Fedora:
$ sudo yum install libav
Step 2: Rename files into a numbered sequence:
Assuming this is your directory that contains the image files:
$ ls -al | head -10
drwxr-xr-x 2 gerrit gerrit 61440 Dec 25 23:25 .
drwx------ 69 gerrit gerrit 4096 Dec 28 10:38 ..
-rw------- 1 gerrit gerrit 67 Dec 25 17:14 .directory
-rw-r--r-- 1 gerrit gerrit 5413562 Dec 25 13:29 IMG_7152.JPG
-rw-r--r-- 1 gerrit gerrit 4659677 Dec 25 13:29 IMG_7153.JPG
-rw-r--r-- 1 gerrit gerrit 5282393 Dec 25 13:29 IMG_7154.JPG
-rw-r--r-- 1 gerrit gerrit 4767624 Dec 25 13:29 IMG_7155.JPG
-rw-r--r-- 1 gerrit gerrit 5094968 Dec 25 13:29 IMG_7156.JPG
-rw-r--r-- 1 gerrit gerrit 5132944 Dec 25 13:30 IMG_7157.JPG
Rename all the files in the directory into a numbered sequence with one-liner:
$ c=1; for f1 in * ; do f2=$(printf "%04d.jpg" $c); ((c+=1)); mv $f1 $f2; done
$ls -al | head -10
-rw-r--r-- 1 gerrit gerrit 5413562 Dec 25 23:33 0001.jpg
-rw-r--r-- 1 gerrit gerrit 4659677 Dec 25 23:33 0002.jpg
-rw-r--r-- 1 gerrit gerrit 5282393 Dec 25 23:34 0003.jpg
-rw-r--r-- 1 gerrit gerrit 4767624 Dec 25 23:35 0004.jpg
-rw-r--r-- 1 gerrit gerrit 5094968 Dec 25 23:35 0005.jpg
-rw-r--r-- 1 gerrit gerrit 5132944 Dec 25 23:35 0006.jpg
-rw-r--r-- 1 gerrit gerrit 5526978 Dec 25 23:35 0007.jpg
It is important that they are numbered like this, starting from 0001, as the next step requires it.
Step 3: Make a Video of your sequential images:
The resizing of the images happens in this step, regardless of the original image size. However, all images should be the same size. In this example, 6 photos are displayed every second (that's the "-r 6" bit), and the resulting frame size will be 640x480 pixels (the "-s vga" bit):
$ avconv -r 6 -i %04d.jpg -s vga my_video.avi
You now have an AVI file called my_video.avi, which you can emded in your web site, upload to YouTube, view on your TV, etc. Consider also creating an animated GIF file, which has other advantages. To make a Flash video file, which has slightly better quality at double the file size, do this:
$ avconv -r 6 -i %04d.jpg -s vga my_video.flv
Here is an example video of 1000 pictures taken over the course of a long, bacchanalian dinner with friends and family. I used the larger Flash video file, which was easier to embed into this content management system (Joomla).