DigiKam to PHP Photo Album

DigiKam to PHP Photo Album

DigiKam to PHP Photo Album

My system for managing photos and publishing them "dynamically" on my website.

Overview

I have been working for a while on a way to organize my photos and make them available to others. The solution that I came up with involves using DigiKam to edit the image/album metadata on my laptop, rsync to push the images and the metadata to my server and some custom PHP1 (with a MySql database) to make them available to view.

As I mentioned above, I'm using DigiKam to organize my images on my laptop. DigiKam is nice enough to store this metadata on the image files as well as in a database. Having this information in database form makes it really easy to leverage for other purposes.

I'm far from complete with this project, but as you can see from the Photo Galleries section of this web site, it's beginning to work reasonably well.

Data Model

The data model is represented by a collection of PHP classes. The structure that I'm using matches the structure used by DigiKam. The fundamental building blocks are Albums and Images. Read more about the implementation in Data Model.

How It works

Using DigiKam, I edit the image metadata on my laptop, then sync the images and the DigiKam database to my server.

On my server, I have a shell script that I run via cron to generate thumbnail images from the originals.

For performance reasons, I denormalize the data from the DigiKam database into a MySql database creating "views" of the album and image data.

Once denormalized, I have a couple of PHP pages to display the data; one for albums and another for individual images.

The pages use custom PHP classes that I call the data model.

One issue that I encountered (especially with "tag" driven galleries) was that rendering the page could take a long time if I had a large number of images; so I have paginated my galleries to a hard-coded number of images per page (currently 21 - 7 rows of 3). The pagination made it annoying for me when viewing images - I'd load a page, view 21 images, then I'd have to close out of the flow, go to page 2, resume the flow and view another 21 pages, etc. This frustration led me to add some JavaScript to automatically load additional images when, during my browsing, I reached the end of the current set of photos. This JavaScript can be seen in group.php.

Visual Presentation

Anyone that knows me knows that making pages pretty is not my strong suit. But I wanted these pages to look reasonably well and I wanted them to function in a way that I would enjoy browsing the albums. I played with several gallery presentation libraries, devoting most of my time to fancybox which I recently replaced with PhotoSwipe. I've settled on PhotoSwipe because I like how well it works on the iPad (where I do a lot of my viewing).

Download

I am happy to share the code that I've used to make this all work. It's all available here:


  1. With the move to gatsby, the PHP portion is no longer used, but may still be valuable to others, thus presented here. The Gatsby re-write will be presented in another document.

Notes related to DigiKam to PHP Photo Album: