Web photo album generator
Web developers frequently create photo albums of full-size and thumbnail images. When a thumbnail is clicked, a large version of the picture is displayed. This requires resizing and placing many images. These actions can be automated with a simple Bash script. The script creates thumbnails, places them in exact directories, and generates the code fragment for <img>
tags automatically.
Getting ready
This script uses a for
loop to iterate over 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, in index.html
.
How to do it...
This Bash script will generate an HTML album page:
#!/bin/bash #Filename: generate_album.sh #Description: Create a photo album using images in current directory echo "Creating album.." mkdir -p thumbs cat <<EOF1 > index.html <html> <head> <style> body { width:470px; ...