PHP Photo Albums: Gallery , Coppermine and 4Images

I just needed a simple web picture gallery application to manage my family’s photos and until now I was using a blog because a couple of years ago I thought we’d be posting cute things about our kid but it turned out that no, we’re just posting pictures for family and friends to see.

There are many of these photo album programs (389 today in Hotscripts ), it seems that nowadays the CMS and photo gallery applications are like the video store applications in the times of DOS, where every computer enthusiast had one made by themselves.

So for the “standards” I looked into the Fantastico package that the web hosting companies offer (a point-and-click collection of scripts). If an application is there it means that is more or less popular and relatively easy to install and maintain. So I see three photo album programs: 4Images, Coppermine and Gallery.

4Images: It’s hard to distinguish the English from the German text in their web site (couldn’t they have used two font colors or two different pages?). Their license is more restricted than the typical open source: “4images may be used and modified free of charge for personal and non-profit use. Commercial use must purchase a Licence.”.

Coppermine and Gallery licenses are GPL, so I’m picking one of them.

Coppermine: Uses the GD image library (that is usually built-in in PHP) and MySQL

Gallery uses NetPBM and ImageMagick image manipulation packages instead of GD. That means one more thing to install but according to the Gallery developer those packages are superior to GD, although the problem of the thumbnail quality has been resolved in GD2 (from GD1). Gallery doesn’t use MySQL.

The features of Coppermine and Gallery may be different but I don’t care because all I needed is a simple photo album manager so I went with Gallery because I liked the simpler design better, although both have enough crazy skins or templates.

There’s a little problem with Gallery (besides the unfortunate name that is so common that is impossible to find the site in a web search) in its downloads or rather in the instructions for them.

For starters, the main download link directs to an empty file list in the sourceforge repository. I selected “show all” and downloaded gallery-1.5-pl1.tar.gz, but the confusion is that there are two sets of the NetPBM binaries for Linux, one with the .zip extension and another one that is tar-ed and gzipped. There’s no indications of which one to use, so of course I went with the gzipped one. Wrong.

The installation wizard (that is very nice by the way) when it was building the config file (last step), complaint that it couldn’t find either the pnmcomp or the pamcomp file and it wouldn’t let me pass that point. So as it happens, none of them are in the gzipped package I downloaded (!). I Searched in Gallery’s forums and it turns out that it’s a very common confusion.

The solution was simple after trying the zipped package; one of the needed PBM executables was there.

It’s worth mentioning that in terms of security Gallery does a good job after installation, because it not only tells you to change the configuration file ownership settings and to delete the installation file, but it provides with a little shell script that will do it for you. I just evaluated another LAMP application that left the critical configuration file (with the MySQL password) world-readable.

So I had my application installed, logged in as Admin and created some albums, everything was OK. The last little problem was that I was using previously just one user and password to protect the blog, so I only need to give this password to friends and family and the rest of the people unfortunately don’t get to see the cutest kid in the world. So I created one Gallery user, but when I direct people to the front page of Gallery, since they are not logged in they are presented with a bleak page that says “no albums, no images” and has a little login icon at the right top corner.

I didn’t want my users to have to figure out that there are already pictures there and they have to log in, so I could have written the instructions, but what I did was a little hack in the login.php file: after the log in has been successful (line 48) I added the redirection to the albums.php page (see below), and instead of presenting this albumspage as the main one, I use the login.php as front page.

print("<html><head>");
print("<meta content = \"0;url=http://www.danielduran.com/gallery/\" http-equiv = \"refresh\">");
print("</meta></head></html>");