Instant Web Gallery
An easy static photograh site

For the last 15 years, my family has put their pictures up on a web server so that friends and families can browse through them. Unfortunately, the images that were put up were not well catalogued, and it was difficult to find a picture even if you knew what you were looking for, and impossible to browse through them, as each image would take several seconds, or even minutes, to load and few of them had names that described their contents.

I wanted to create a tool that would build an easy to use photo gallery website around an existing collection of images. Having just used Django to create my own web photo gallery for this site I decided that I base this project on the Django template engine, and reuse some of my old photo gallery templates. I made the script produce a static website, as I felt that would result in the easiest maintenance, and least worry about security.

The finished script recursively iterates through a directory tree full of images, creating thumbnails and resized images along the way. It then creates an html page in each folder which smartly displays images and subfolders for that node. Images are displayed in an Ajax photo gallery, and directories are displayed with several preview thumbnails to make it easy to determine their contents.

Here is an example of a picture dump before and after being converted, and here is a copy of the script. All of the code is GPL, and was written by me. The styling was done by the talented Brendan Stromberger.

In order to run the script, you need to open the python script and make a change. The url_prefix variable needs to be set to the root URL of the site you are building. Optionally, magic_char needs to be set to a character that does not occur in any of the images or folders of the gallery structure. The script will use this character to denote any files that it creates to avoid duplicating them on later runs, and to clean up if you want to remove the site. In order to make sure that there are no conflicting file names, use the command 'python buildsite.py clean '. Once you are confident that everything is set up properly, use the command 'python buildsite.py make ' to build the site. Later, if you ever wish to update the site, you can just re-run that command and the script will rebuild the changed parts without recreating all of the thumbnails that haven't changed.

If you have any questions or comments about this gallery, feel free to leave them here. I would be especially interested to hear if anyone uses this script for themselves.

Comments: