Easy photo galleries with Sigal
Sigal is a "simple static gallery generator" with a straightforward design, a nice feature set, and great themes. It was started as a toy project, but has nevertheless grown into a sizable and friendly community. After struggling with maintenance using half a dozen photo gallery projects along the way, I feel I have found a nice little gem that I am happy to share with LWN readers.
CMS vs. SSG
Sigal is part of a growing family of static site generators (SSG), software that generates web sites as static HTML files as opposed to more elaborate Content Management Systems (CMS) that generate HTML content on the fly. A CMS requires specialized server-side software that needs maintenance to keep up to date with security fixes. That software is always running and exposed on the network, whereas a site generated with an SSG is only a collection of never-changing files. This drastically reduces the attack surface as visitors do not (usually) interact with the software directly. Finally, web servers can deliver static content much faster than dynamic content, which means SSGs can offer better performance than a CMS.
![Sigal photo [Sigal photo]](https://static.lwn.net/images/2018/sigal-montreal-sm.png)
Having contributed to a major PHP-based CMS for over a decade, I was glad to finally switch to a SSG (ikiwiki) for my own web site three years ago. My photo gallery, however, was still running on a CMS: after running the venerable Gallery software (in hibernation since 2014), then Coppermine, I ended up using Piwigo. But that required a PHP-enabled web server, which meant chasing an endless stream of security issues. While I did consider non-PHP alternatives like MediaGoblin, that seemed too complicated (requiring Celery, Paste, and PostgreSQL). Really, static site generators had me hooked and there was no turning back.
Initially, I didn't use Sigal, as I first stumbled upon
PhotoFloat. It is the
brainchild of Jason A. Donenfeld—the same person behind the
pass
password manager that we previously covered and the
WireGuard virtual private network (VPN) as
well. PhotoFloat is a small
Python program that generates a static gallery running custom JavaScript
code. I was enthusiastic about the project: I packaged it for
Debian and published patches to implement RSS feeds and
multiple gallery support. Unfortunately, patches from
contributors would just sit on the mailing list without feedback for
months which led to some users forking the project. Donenfeld
was not happy with the result; he decried the new PHP dependency
and claimed the fork introduced a directory traversal
vulnerability. The fork now seems to be more active than the
original and was renamed to MyPhotoShare. But at that point,
I was already looking for alternatives and found out about Sigal when
browsing a friend's photo gallery.
What is Sigal?
Sigal was created by a French software developer from Lyon, Simon Conseil. In an IRC interview, he said that he started working on Sigal as a "toy project to learn Python", as part of his work in Astrophysics data processing at the Very Large Telescope in Chile:
![Sigal video [Sigal video]](https://static.lwn.net/images/2018/sigal-video-sm.png)
Before starting a new project from scratch, Conseil first looked for alternatives ("Gallerize, lazygal, and a few others") but couldn't find anything satisfactory. He wanted to reuse ideas from Pelican, for example the Jinja2 template engine for themes and the Blinker plugin system, so he started his own project.
Like other static gallery generators, Sigal parses a tree of images
and generates thumbnails and HTML pages to show those images. Instead
of deploying its own custom JavaScript application for browsing images
in the browser, Sigal reuses existing applications like Galleria,
PhotoSwipe, and Colorbox.
Image metadata is parsed from
Exif
tags, but a Markdown-formatted text
file can
also be used to change image or album titles, description, and
location. The latest 1.4 release can also
read metadata from in-image IPTC tags. Sigal parses regular
images using the Pillow library but can also read video files,
which get converted to browser-readable video files through the
ubiquitous FFmpeg. Sigal has good (if minimal) online
documentation and, like any good Python program, can be installed
with pip
; I am working on packaging
it for Debian.
Plugins offer support for image or copyright
watermarks. The adjust
plugin also allows for minor image
adjustments, although those apply to the whole gallery so it is
unclear to me how useful that plugin really is. Even novice
photographers would more likely make adjustments in a basic image
editor like Shotwell, digiKam, or maybe even GIMP before
trying to tweak images in a Python configuration file. Finally,
another plugin provides a simple RSS feed, which is useful to allow users to
keep track of the latest images published in the gallery.
Future plans and limitations
When I asked him about future plans, Conseil said he had "no roadmap":
For me Sigal has been doing its job for a long time now, but the cool thing is that people find it useful and contribute. So my only wish is that this continues and to help the project live for and by its community, which is slowly growing.
Following this lead, I submitted patches and ideas of my own to the project while working on this article. The first shortcoming I have found with Sigal is the lack of access control. A photo gallery is either private or world-readable; there is no way to restrict access to only some albums or photos. I found a way, however, to implement folder password protection using the Basic authentication type for the Apache web server, which I documented in an FAQ entry. It's a little clunky as it uses password files managed through the old htpasswd command. It also means using passwords and, in my usability tests, some family members had trouble typing my weird randomly generated passwords on their tablets. I would have preferred to find a way to use URL-based authentication, with an unguessable one-time link, but I haven't found an easy way to do this in the web server. It can be done by picking a random name for the entire gallery, but not for specific folders, because those get leaked by Sigal. To protect certain pictures, they have to be in a separate gallery, which complicates maintenance.
![Sigal albums [Sigal albums]](https://static.lwn.net/images/2018/sigal-albums-sm.png)
Which brings us to gallery operation: to create a Sigal gallery, you
need to create a configuration file and run the sigal build
command. This is pretty simple but I think it can be made even
simpler. I have proposed having a default configuration file so
that creating a configuration file isn't required to make new
galleries. I also looked at implementing a "daemon" mode that would
watch a directory for changes and rebuild when new pictures show
up. For now, I have settled on a quick
hack based on the entr
utility but there's talk of implementing the feature directly in the
build command. Such improvements would enable mass hosting of
photo galleries with
minimal configuration. It would also make it easier to create
password-less private galleries with unique, unguessable URLs.
Another patch I am working on is the stream plugin, which creates a new view of the gallery; instead of a folder-based interface, this shows the latest pictures published as a flat list. This is how commercial services like Instagram and Flickr work; even though you can tag pictures or group them by folder, they also offer a unified "stream" view of the latest entries in a gallery. As a demonstration of Sigal's clean design, I was able to quickly find my way in the code base to implement the required changes to the core libraries and unit tests, which are now waiting for review.
In closing, I have found Sigal to be a simple and elegant project. As it stands, it should be sufficient for basic galleries, but more demanding photographers and artists might need more elaborate solutions. Ratings, comments, and any form of interactivity will obviously be difficult to implement in Sigal; fans of those features should probably look at CMS solutions like Piwigo or the new Lychee project. But dynamic features are perhaps best kept to purpose-built free software like Discourse that embeds dynamic controls in static sites. In any case, for a system administrator tired of maintaining old software, the idea of having only static web sites to worry about is incredibly comforting. That simplicity and reliability has made Sigal a key tool in my amateur photographer toolbox.
A set of demos is available for readers who want to see more themes and play around with a real gallery.
Index entries for this article | |
---|---|
GuestArticles | Beaupré, Antoine |
Posted Mar 7, 2018 1:16 UTC (Wed)
by anarcat (subscriber, #66354)
[Link] (1 responses)
Posted Mar 8, 2018 12:38 UTC (Thu)
by kena (subscriber, #2735)
[Link]
Posted Mar 8, 2018 9:50 UTC (Thu)
by ededu (guest, #64107)
[Link] (1 responses)
Posted Mar 10, 2018 10:27 UTC (Sat)
by huftis (guest, #58900)
[Link]
Posted Mar 10, 2018 6:43 UTC (Sat)
by Per_Bothner (subscriber, #7375)
[Link]
Here is a sample. In addition to per-image captions, you can have text that introduces a page or a section. There is also a nice "slider" mode.
Originally, you needed to write a tedious XML file listing each picture, but gradually I made it more automatic - for example you can add captions with Digikam that the script will find.
There are some problems. The generator scripts are written in a combination of Java, XQuery, and shell. They also only work on one folder (album) at a time; a tree of albums has to be written by hand. The browser JavaScript only works so-so on mobile phones, partly because the resize-to-fit logic fights with the browser zoom features.
In spite of this, I'm pretty happy with the basic look-and-feel of each album; perhaps someone could use some of my ideas.
Posted Mar 10, 2018 10:20 UTC (Sat)
by huftis (guest, #58900)
[Link] (1 responses)
One rather nice feature of Sigal is that it supports ‘smart’ cropping. If one specifies It usually works well, but not always. And it’s not a real face detection algorithm, which would probably work better (for photos with people in them, of course). And there doesn’t seem to be a way of applying it just to thumbnails, not to the full-size images.
Posted Mar 12, 2018 15:50 UTC (Mon)
by anarcat (subscriber, #66354)
[Link]
Here are the issues opened upstream in the writing of this article:
Easy photo galleries with Sigal
And pull requests:
I am also significantly involved in:
Phew!
Thank heavens!!
Local use
It generates normal HTML and JPEG files, which can be read by a browser from the filesystem, so sure, it could be used as an offline image gallery. But it just generates a gallery of images, so it’s not useful for actually organising the images. For organising them, both digiKam and KPhotoAlbum works well.
Local use
I wrote my own qalbum static gallery generator with some nice features.
The images are automatically re-sized to fill the window - I hate wasting screen real estate. (You can also pan with the mouse or zoom with a scroll-wheel.)
Easy photo galleries with Sigal
Smart cropping feature
img_processor = 'SmartResize'
, it will use Pilkit’s entropy-based cropping algorithm. This will basically centre the image on the ‘busiest’ (usually the most interesting) part of the image. The end result is typically fewer case of people’s heads being cut off.Smart cropping feature