Web photo album generator
Web developers commonly design photo album pages for websites that consist of a number of image thumbnails on the page. When thumbnails are clicked, a large version of the picture will be displayed. However, to do this, many images are required. Afterwards, copying the <img>
tags, resizing the image to create a thumbnail, placing them in the thumbs
directory, and so on, is a real hurdle. As with any repetitive task, this can be automated easily by writing a simple bash
script. By writing a script, we can create thumbnails, place them in exact directories, and generate the code fragment for <img>
tags automatically in few seconds. This recipe will do exactly this.
Getting ready
We can perform this task with a for
loop that iterates every image in the current directory. The usual Bash utilities such as cat
and convert
(from the Image Magick package) are used. These will generate an HTML album, using all the images, to index.html
.
How to do it...
Let's write...