Creating HTML Picture Galleries with Picfolio and Image Magick
July 19, 2008Perhaps I am old-fashioned, but I like to have picture galleries that can be burned to CDs and DVDs and viewed both in DVD-Players and computers.
Furthermore, I want that to run automatically, script-based. Most of the available programs either require a database or user interaction, thus some years ago I found picfolio, a small tool that runs on Linux and contains XML-based configuration and templates. Together with the tools from the Image Magick package I build a little shell script that does exactly the job I need.
Sadly, Picfolio seems to have vanished from the web, but luckily I have both the src.rpm and the Suse RPM here. And they are running on every Suse box since Version 9.x.
Here is what I need to do on a new system to get Picfolio running:
- Install the picfolio-RPM.
- Copy my three preconfigured XML-Files to ~/.picfolio
- Create a “picfolio root configuration” in the gallery directory (not necessary, but safer..) This directory named picofolio contains a file named config.xml.
- Execute the gallery script I created (see below)
After that, I have index files with previews, clickable photo pages, the images are rotated according to their exif informations. The latter are also displayed in the gallery. Furthermore, all images hava a watermark with my copyright and e-mail-adress. the script seems robust (at least according to my limited coding skills
…), and it works with thousands of images. However, there are some ugly recursive chown and move-commands, so use it at your own risk only!
This is my config.xml:
<?xml version=”1.0″?>
<config root=”yes” version=”0.3.1″>
<nails thumbnail-size=”128″ midnail-size=”640″/>
<stylesheets index=”/home/mfeilner/.picfolio/index.xsl” page=”/home/mfeilner/.picfolio/page.xsl”>
<param name=”image-columns” select=”‘5′”/>
<param name=”subdir-columns” select=”‘4′”/>
</stylesheets>
<index max-images=”20″ sort-by=”title”/>
<track-mtime count=”6″ sort-by=”title”/>
<subdirs/>
</config>
The picfolio.xml is created automatically and holds a list of images found.
Here comes my create-gallery script:
#! /bin/bash
#######################################################
#
# Das Programm “convert” wandelt Bilddateien in Webfähige Bilder um:
# Befehlssyntax zur Umwandlung von Digicam-Bildern in webfähige Gallery-Vorlagen ans shell:
# for i in *JPG; do convert -resize 800×533 -quality 50 -font helvetica -pointsize 20 -fill grey -draw “text 250,510 ‘Property Of Markus Feilner 2005′” $i `basename $i .JPG`_small_wasserzeichen.JPG; done
#
# Das folgende Skript wandelt .JPG Dateien (Canon EOS 300 D)
# auf 800×533 pixel, 50% jpg-qualitaet um
#
# Die Dateien werden mit Wasserzeichen versehen
# und anschliessend mit “jhead” anhand der exif-informationen aus den Bildern rotiert.
# Die großen Originalbilder werden gelöscht.# Das Programm picfolio erstellt dann eine Bildergalerie mit den Informationen aus den lokalen und den # XML-Vorlagen in /usr/share/picfolio - vor allem de HTML-Schnipseln aus der Datei master.xml.
# Ausserdem werden in den lokalen Verzeichnissen XML-Dateien hinterlegt,
# die für die einzelnen Galerien Definitionen enthalten.
#
# Meine Kamera liefert die Bilder mit .JPG - Erweiterung, um “.jpg” Dateien aus allen
# Unterverzeichnissen in “.JPG” umzubennen, dient z.B. die Schleife hier:
# for i in `find -name *jpg`; do mv $i `echo $i | sed s/.jpg/.JPG/g` ; done
#
#
#
#######################################################
# Zwei Pfad-Variablen definieren
workdir=`pwd`
dirs=`find $workdir -type d`
JPG_total=0
# Die Schleife, die uns in die Verzeichnisse führt…
for d in $dirs
do
cd “”$d”"
# Wo sind wir denn gerade?
echo “Suche nach .JPG Dateien in $d:”
# Ein test, damit das folgende nur ausgeführt wird, wenn überhaupt .JPG-Dateien da sind.
# - und etwas Statistik sammeln …
JPG_amount=`ls -l | grep JPG | wc -l`
JPG_total=$(( $JPG_total + $JPG_amount ))
echo “$JPG_amount .JPG Dateien gefunden.”
if (( $JPG_amount > 0 ));
then
# für jedes JPG die conversion anstossen. Vorher noch dem Besitzer Schreibrechte geben.
JPGs=`find *JPG`
for i in $JPGs;
do echo “$i found in $d, … converting…”
chmod u+w -R $i
# für waagrechte und normale Bilder:
/usr/bin/convert -resize 800×533 -quality 80 -font helvetica -pointsize 20 -fill grey -draw “text 10,510 ‘(c) Property Of Markus Feilner, mfeilner@feilner-it.net‘” $i `basename $i .JPG`_sw.jpg;
# das gleiche für hochkantige Bilder… vielleicht braucht man das mal …
#/usr/bin/convert -resize 533×800 -quality 80 -font helvetica -pointsize 20 -fill grey -draw “text 10,760 ‘(c) Property Of Markus Feilner, mfeilner@feilner-it.net’” $i `basename $i .JPG`_sw.jpg;
echo “$i wurde gelöscht.”;
rm $i;
done;
else
# Sonst ist nichts zu tun.
echo “Keine JPG-Dateien in diesem Verzeichnis gefunden.”
fi
# Jhead rotiert die Bilder, nach den Exif-Informationen
find *jpg -exec /usr/bin/jhead -autorot {} \;
cd $workdir
done
#picfolio erstellt eine Galerie und gibt ausführlich Auskunft.
echo ‘Erstelle Galerien und Untergalerien mit picfolio:’
/usr/bin/picfolio -v
echo “Fertig. $JPG_total .JPG Dateien umgewandelt.”
Posted by mfeilner
