Welcome!

Linux Authors: Michael Sheehan, Lavenya Dilip, Ian Thain, Bruce Armstrong, Ellen Rubin

Related Topics: Linux

Linux: Article

Put the family album online with Linux

Can a Perl script and a handful of templates and config files put Grandma's album to shame?

This column stems from a gift a reader sent me. I blamed my wild-eyed prognostications for 2001 on dreams I had one night after enjoying some particularly potent habanero peppers (see Resources for a link). After finding out that I really liked the hot stuff, the reader sent me a sampler of Panamanian habanero salsas. Wow! I tried some of that hot salsa on my Sunday omelet and it burned the "same-old, same-old" right out of me. In fact, it put me in a different mood completely. After that breakfast, I needed to experiment, to find and try new applications I had never seen before, to do something novel. As my namesake Papa Jack would say, "I had them pioneer blues."

A lot of my experimentation lately has been about graphics: cameras, printers, and scanners. It dawned on me that it was time to do something productive with all those toys. I decided to put together an online photo album so that friends and family could easily keep up with the latest happenings in my life, and maybe share rare old family photos that up until now could be enjoyed only in person.

I began my latest expedition the same way I've started many others, by visiting Freshmeat.net (see Resources for a link). Searching for "album" returned almost 60 possibilities. I'm sure that I missed a lot of good ones, but I quickly found one that not only had the features I wanted, but also had precious few dependencies, and promised to be easy enough for even a dweeb journalist to install. So I chose LiveFrame Gallery, an application for Web-based photo albums. It is under the GPL, and was written and maintained by James Home.

The application consists of a Perl script, a handful of templates to control how the pages look when displayed, and a couple of configuration files. Of course you need to have access to a Web server in order to use LiveFrame Gallery. Since I wanted to display thumbnails in the albums, I also downloaded and installed a copy of ImageMagick. According to the LiveFrame Gallery homepage, future versions will include everything needed to handle batch image processing for the creation of thumbnails, but it's not soup yet. In the meantime, there are at least two Perl script add-ons for LiveFrame that handle a lot of the drudgery of manually sizing photos and creating thumbnails. You can find both of them on the Contributions page of the LiveFrame Gallery Website (see Resources for a link).

Setting up LiveFrame on my Web server was easy. Use the instructions from the Website if you're going to install it. I'm itemizing the steps I took only to show how easy installation is.

  • Download the current version
  • Decompress the downloaded file
  • Move liveframe.cgi to Apache's cgi-bin directory
  • Tailor the configuration in liveframe.cgi as required
  • Move the lfdir directory to the root HTML directory

That's it. At that point I could run liveframe.cgi by entering the URL that pointed to it. Naturally, I got tired of doing that pretty quickly, so I added a link to my homepage that triggered execution of the script with a simple click. But even though LiveFrame was working, I wasn't nearly done. All I could do at that point was look at the three sample albums that come with the download.

It's a fact of life that one of the first things I do after installing new software is break it. That expedition was no exception. But the damage was minimal and the fix was easy. LiveFrame Gallery needs to find at least three album directories in order to present the start page. Moreover, these albums must be correctly configured. If you add a new one and it's not configured right, you won't be able to see any of them. The point I am trying to make here is this: heed the documentation and don't get rid of the three sample albums until you have three working albums of your own.

But creating a new album is no hill for a stepper. You begin by creating a subdirectory for it in the galleries directory, one of two subdirectories that live within the lfdir directory. Inside each album directory lives a simple text configuration file called config and two more directories: display and preview. The images you want to display go in display, and the thumbnails go in preview.

The configuration file contains the name of the album and the names of the images. You can add comments that will appear at the bottom of the image. The images will appear in the order in which the image names show up in the config file. The image and the thumbnail must share the same name. If that sounds complicated, it's not. Here is an example of a config file:

 # the next name is the album title
 LinuxWorld Conference Expo
 # the next three lines contain images and comments,
 # separated by }
 lwce-001.jpg}Crowd awaits the opening bell
 lwce-002.jpg}Linus waves from tutorial room
 lwce-003.jpg}Bill Gates visits Red Hat booth 

Nothing to it. The first uncommented line is the title, the next uncommented lines contain the image filename, a separator (the "}" character), and a comment about the image. Image comments are not required, but they can add a lot to the album. There are templates and style sheets that live in a directory apart from the gallery albums. If you want to modify the appearance of the pages as they display the images, all you need to do is hack the appropriate HTML. My dweeb nature forced me to change a few things, just to see if I could. So my albums have white text on a black background instead of the other way around. Not very daring, but you can get as rad as you like.

I would guess that it took me about half an hour from the time I downloaded LiveFrame Gallery and worked with the samples until I had an album of my own. I spent a lot more time resizing the images and creating thumbnails of them than I did setting up LiveFrame. That's where the two Perl-script add-ons that I mentioned at the top come in: they automate a lot of that work. Both require ImageMagick so that they can access its command line interface. I used this command to resize the images to 640x480:

convert imagefile-1 -geometry 640x480 imagefile-2

Creating thumbnails is done in exactly the same way, except that the geometry is changed to get the size desired:

convert imagefile-1 -geometry 64x48 imagefile-2

You can accomplish the same thing using the GIMP and a mouse, but it's a lot quicker from the command line.

I spent a couple of hours selecting the pictures, resizing them, making thumbnails, and moving them to the appropriate directories. Now I have three living photo albums that I can share with friends and family on a nearly realtime basis. All because James Home decided to scratch an itch.

Home is not a professional programmer; he is an interface designer. A combination of things led him to create LiveFrame, including the length of time it took to build image displays by hand and the poor user interfaces he found in existing open source alternatives. This history is important to Home, so here are his words on the subject:

I built LiveFrame because I was taking dozens of photos a week, and building custom HTML interfaces for each set of images, which was extremely labor intensive. When I looked for an automated replacement, I discovered that many of the publicly available image viewers that I saw, like a lot of open source software in general, suffered from an inattention to user interface. If anything, I hope LiveFrame's popularity will encourage more open source programmers to seek out designers to work with on their projects, or even encourage more technically oriented designers to take on programming projects of their own.

I don't know about you, dear reader, but I think Papa Jack would agree with me when I say that James Home has a pretty good case of the pioneer blues himself. Thanks to the free software and open source community, more and more bright young pioneers like Home are finding ways to scratch their own itches and benefit the whole community at the same time. Not to mention that they also make open source look increasingly attractive to those outside.

More Stories By Joe Barr

Joe Barr is a freelance journalist covering Linux, open source and network security. His 'Version Control' column has been a regular feature of Linux.SYS-CON.com since its inception. As far as we know, he is the only living journalist whose works have appeared both in phrack, the legendary underground zine, and IBM Personal Systems Magazine.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.