Creating HTML Picture Galleries with Picfolio and Image Magick

Perhaps I am old-fashioned, but I like to have static picture galleries that can be burned to CDs and DVDs and viewed both in DVD-Players and computers without a huge database behind.

Furthermore, I want that to have a script run automatically, creating galleries of files just dropped into a directory. Most of the available programs either require a database or user interaction, or both. Thus I kept searching and 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 built a little shell script that does exactly the job I need. According to its manpage (see below) it turns any a directory tree into a html photo gallery.

Sadly, Picfolio (developed by Peter Jones) seems to have vanished from the web since this version, but luckily I have both the src.rpm and the Suse RPM, and they are running on every Suse box since Version 9.x, including 10.3.

Here is what I need to do on a new system to get Picfolio running:

  • Install the picfolio-RPM with rpm -i, install libxslt and libxml.
  • Copy three preconfigured, adapted XML-Files to ~/.picfolio. These files are the templates from which picfolio will generate the index.html pages for every subdirectory and the html pages for every picture.
  • Then I create a so-called “picfolio root configuration” in the gallery’s top-level directory (this is not necessary, because it can be created on the fly, but I consider it a little safer..) This directory named picofolio contains a file named config.xml. (see below).
  • Last step: Execute the gallery script I created (see below) The script does some Image Magick like automatic flipping, resizing and optimized jpeg compression for the web.

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, if you like. 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!

My cameras deliver the images with names in capital letters, ending in .JPG. If your’s doesn’t, well, good luck. I usually use some shell command for that, but you may use krename or other tools as well.

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′”/>
<index max-images=”20″ sort-by=”title”/>
<track-mtime count=”6″ sort-by=”title”/>

The XSL-files that act as a sort of template for the latter XML are referenced here. I suggest to use different files in diefferent locations per project. The XSL files are relatively simple to understand, though careful editing is required, the error messages that picfolio -dfv gives are not very explicit.

The picfolio.xml is created automatically and holds a list of images found.

Here comes my create-gallery script:

#! /bin/bash

dirs=`find $workdir -type d`

for d in $dirs
cd “”$d””
echo “Suche nach .JPG Dateien in $d:”
JPG_amount=`ls -l | grep JPG | wc -l`
JPG_total=$(( $JPG_total + $JPG_amount ))
echo “$JPG_amount .JPG Dateien gefunden.”
if (( $JPG_amount > 0 ));
JPGs=`find *JPG`
for i in $JPGs;
do echo “$i found in $d, … converting…”
chmod u+w -R $i
/usr/bin/convert -resize 800×533 -quality 80 -font helvetica -pointsize 20 -fill grey -draw “text 10,510 ‘(c)
Property Of Markus Feilner,‘” $i `basename $i .JPG`_sw.jpg;
echo “$i wird gelöscht.”;
rm $i;
echo “Keine JPG-Dateien in diesem Verzeichnis gefunden.”
find *jpg -exec /usr/bin/jhead -autorot {} \;
cd $workdir


echo ‘Erstelle Galerien und Untergalerien mit picfolio:’
/usr/bin/picfolio -v
echo “Fertig. $JPG_total .JPG Dateien umgewandelt.”

This is (or was) the manpage of Picfolio:

picfolio – generate photo galleries

picfolio [options]

Picfolio will turn a directory tree of images into a photo gallery. All information about the photo gallery is kept in XML files. Those XML files are then translated into the gallery HTML files using XSLT stylesheets.

When you run Picfolio, it will begin to look for a root configuration file in the current directory. If that file is not found, it will walk up the directory tree until it finds a root configuration file.

After the root configuration file is found, Picfolio will start from that directory and generate the photo gallery.

-c, –create
Create a non-root configuration file in the current directory. The configuration will effect this directory and all sub-directories.
-r, –root
Create a new root configuration file in the current directory. You should only have one root configuration file per photo gallery. The path to the root configuration file is used when generating relative paths.
-d, –debug
Print lots of verbose information while the photo gallery is being generated.
-f, –force
Normally, Picfolio will only rebuild the parts of the gallery that have changed. You can use this flag to make Picfolio recreate the entire gallery even if it is not necessary.
This can be useful if you are making changes to your stylesheets and want to get Picfolio to recognize those changes. Using the –save-xml command line option will turn on this option. If this were not the case, you would not see XML files unless the gallery had changed.
-m, –no-midnails
Generate the photo gallery as usual, but donŽt create any midnails, even if some are missing.
-n, –no-nails
Generate the photo gallery as usual, but donŽt create any thumbnails or midnails, even if some are missing.
-t, –no-thumbnails
Generate the photo gallery as usual, but donŽt create any thumbnails, even if some are missing.
-x, –save-xml
Save temporary, in-memory only XML files to disk. This includes XML files that are feed to the XSLT engine. This is helpful for people who are trying to create a custom stylesheet.
-s, –skip-unknown
Do not add images to the XML files if they are not already listed in them. This means that Picfolio will only generate the photo gallery based on what it has recorded in the XML files, and will not look for new images.
-u, –upgrade
When upgrading Picfolio from an older version, you might need to use this option to upgrade the gallery files so that Picfolio will work correctly.
-v, –verbose
Print verbose information to stdout while the photo gallery is being generated.
-V, –version
Print the Picfolio version number and exit.
Please report any bugs by visiting
Picfolio was first written in March of 2003. For more information about Picfolio, please visit

Peter Jones <>
October 1, 2003


Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: