KISS static web photo albums with `photoalbum.sh`

Published at 2023-10-29T22:25:04+02:00

Once in a while, I share photos on the inter-web with either family and friends or on my The Irregular Ninja photo site. One hobby of mine is photography (even though I don't have enough time for it - so I am primarily a point-and-shoot photographer).

I'm not particularly eager to use any photo social sharing platforms such as Flickr, 500px (I used them regularly in the past), etc., anymore. I value self-hosting, DIY and privacy (nobody should data mine my photos), and no third party should have any rights to my pictures.

I value KISS (keep it simple and stupid) and simplicity. All that's required for a web photo album is some simple HTML and spice it up with CSS. No need for JavaScript, no need for a complex dynamic website.

Table of Contents

Introducing `photoalbum.sh`

`photoalbum.sh` is a minimal Bash (Bourne Again Shell) script for Unix-like operating systems (such as Linux) to generate static web photo albums. The resulting static photo album is pure HTML+CSS (without any JavaScript!). It is specially designed to be as simple as possible.

Installation

Installation is straightforward. All required is a recent version of GNU Bash, GNU Make, Git and ImageMagick. On Fedora, the dependencies are installed with:

Now, clone, make and install the script:

You should now have the `photoalbum` command in your `$PATH`. But wait to use it! First, it needs to be set up!

Setting it up

Now, it's time to set up the Irregular Ninja static web photo album (or any other web photo album you may be setting up!)! Create a directory (here: `irregular.ninja` for the Irregular Ninja Photo site - or any oter sub-directory reflecting your album's name), and inside of that directory, create an `incoming` directory. The `incoming` directory. Copy all photos to be part of the album there.

In this example, I am skipping the `cp ...` part as I intend to use an alternative `incoming` directory, as you will see later in the configuration file.

The general usage of `potoalbum` is as follows:

Whereas:

So what we will do next is to run the following inside of the `irregular.ninja/` directory; it will generate a `Makefile` and a configuration file `photoalbumrc` containing a few configurable options:

In the case for `irregular.ninja`, I changed the defaults to the following:

So I changed the album title, adjusted some image and thumbnail dimensions, and I want all images to be randomly shuffled every time the album is generated! I also have all my photos in my Nextcloud Photo directory and don't want to copy them to the local `incoming` directory. Also, a tarball containing the whole album as a download isn't provided.

Generating the static photo album

Let's generate it. Depending on the image sizes and count, the following step may take a while.

The result will be in the distribution directory `./dist`. This directory is publishable to the inter-web:

I usually do that via rsync to my web server (I use OpenBSD with the standard `httpd` web server, btw.), which is as simple as:

Have a look at the end result here:

https://irregular.ninja

PS: There's also a server-side synchronisation script mirroring the same content to another server for high availability reasons (out of scope for this blog post).

Cleaning it up

A simple `make clean` will clean up the `./dist` directory and all other (if any) temp files created.

HTML templates

Poke around in this source directory. You will find a bunch of Bash-HTML template files. You could tweak them to your liking.

Conclusion

A decent looking (in my opinion, at least) in less than 500 (273 as of this writing, to be precise) lines of Bash code and with minimal dependencies; what more do you want? How many LOCs would this be in Raku with the same functionality (can it be sub-100?).

Also, I like the CSS effects which I recently added. In particular, for the Irregular Ninja site, I randomly shuffled the CSS effects you see. The background blur images are the same but rotated 180 degrees and blurred out.

`photoalbum.sh` source code on Codeberg.

E-Mail your comments to `paul@nospam.buetow.org` :-)

Other Bash and KISS-related posts are:

2025-09-14 Bash Golf Part 4

2024-04-01 KISS high-availability with OpenBSD

2023-12-10 Bash Golf Part 3

2023-10-29 KISS static web photo albums with `photoalbum.sh` (You are currently reading this)

2023-06-01 KISS server monitoring with Gogios

2022-01-01 Bash Golf Part 2

2021-11-29 Bash Golf Part 1

2021-09-12 Keep it simple and stupid

2021-06-05 Gemtexter - One Bash script to rule it all

2021-05-16 Personal Bash coding style guide

Back to the main site