#! /bin/bash # sphinx - Simple Picture Html INdeXer, by Daniele Raffo # Released under the GPL License if [ ! -z "$1" ] then echo " sphinx - Simple Picture Html INdeXer Copyright (C) Daniele Raffo v3.2.1 (18.01.2008) This script indexes picture files into a HTML album. Usage: bash ./sphinx (The following instructions make reference to constants in sphinx.cfg, the configuration file for sphinx. I recommend that you modify just the file sphinx.cfg, and leave this script unchanged -- unless you really want to.) This program generates two index pages with links to each picture: a $INDEX_FILE with picture descriptions, and a $TH_INDEX_FILE with thumbnails. In both indexes, each entry links to a picture enframed in a black page, with links to the previous and next picture and back to the two index pages. For both indexes, it is possible to classify the images into sections. Each entry in the indexes is the file's description, as parsed from the $DESCRIPTOR_FILE; this is a plaintext file which you write to describe your album, formatted as follows: TITLE Section Alpha image1.jpg Description Of First Image image2.jpg Description Of Second Image image3.gif Description Of Third Image TITLE Section Beta my_img.png Description Of Another Image imageV.jpg Description of the Fifth Image EOF Hence the TITLE codeword identifies a section. The descriptor file must end with the codeword EOF. The thumbnails are automatically generated by a call to ImageMagick. This program was designed to create a photographic album; to use it for other kinds of pictures, just replace the strings as appropriate. You can download the latest version of this program from http://www.crans.org/~raffo/projects/sphinx Report comments and bugs to . This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ImageMagick is Copyright (C) 1999-2004 ImageMagick Studio LLC. " exit 0 fi if [ ! -e ./sphinx.cfg ] then echo "Error: configuration file sphinx.cfg not found" exit 1 fi source ./sphinx.cfg if [ ! -e $DESCRIPTOR_FILE ] then echo "Error: descriptor file $DESCRIPTOR_FILE not found" exit 1 fi if [ ! -e $TH_DIR ] then mkdir $TH_DIR fi set +o noclobber rm -f $INDEX_FILE $TH_INDEX_FILE # Create indexes' header echo " Photographs by $AUTHOR $HEAD_TAGS
Photographs by $AUTHOR

" | tee $TH_INDEX_FILE > $INDEX_FILE # Read the descriptor file, create thumbnails, complete indexes line="" n_pic=0 current_title="Top" while [[ "$line" != EOF* ]] do read line if [[ "$line" == EOF* ]] then break elif [[ $line == TITLE\ * ]] then # Title of a section current_title=${line#TITLE } echo "

" | tee -a $TH_INDEX_FILE >> $INDEX_FILE else # Picture description file_list[$n_pic]="${line%% *}" descr_list[$n_pic]="${line#* }" title_belong[$n_pic]="$current_title" echo "


" >> $INDEX_FILE echo "" >> $TH_INDEX_FILE echo -n "$PIC_DIR${file_list[$n_pic]}: " if [ ! -e $PIC_DIR${file_list[$n_pic]} ] then echo "(Warning) picture file does not exist" else if [ -e $TH_DIR$TH_PREFIX${file_list[$n_pic]} ] then echo "thumbnail already exists" else echo "generating thumbnail" convert -antialias -geometry 120x60 $PIC_DIR${file_list[$n_pic]} $TH_DIR$TH_PREFIX${file_list[$n_pic]} fi fi let n_pic++ fi done < $DESCRIPTOR_FILE echo "

" >> $INDEX_FILE echo "

no thumbnails
" >> $TH_INDEX_FILE echo "


Album automatically created by sphinx v$VERSION on $DATETIME.

" | tee -a $TH_INDEX_FILE >> $INDEX_FILE # Create frames let last_pic=$n_pic-1 for ((i=0; i < n_pic; i++)) do if [ "$i" -eq 0 ] then prev_link="" next_link="" elif [ "$i" -eq "$last_pic" ] then prev_link="" next_link="" else prev_link="" next_link="" fi echo " ${title_belong[$i]}: ${descr_list[$i]} - Photograph by $AUTHOR $HEAD_TAGS
$prev_link $next_link

$prev_link $next_link
" > ${file_list[$i]/%.*/.html} done chmod 644 *.html $PIC_DIR* $TH_DIR* chmod 711 $PIC_DIR $TH_DIR exit 0