Raspberry HomeGallery for self-hosted family photos
The Raspberry Pi in my local LAN runs a self-hosted, local photo gallery. I do not feel comfortable uploading family photos into the internet cloud since I do not want them to leak and become public.
In this blog post I want to share my experience with the open-source photo gallery HomeGallery suitable to host tens of thousands of photos on a Raspberry Pi for access with different screen-sizes (desktop computers and smartphone). I absolutely love it! The UI concept and the performance are great.
You find more information on the project homepage or you can just try out the demo site. Here I want to focus in the installation and the image/video imports.
Disclaimer: this gallery is a small open source project. Some developers spend their free-time to implement it and share it with the world. As for all software there are bugs or details missing in the documentation. If you find something which can be improved you can open an issue or, even better, fix it and create a pull-request.
Installation on my Laptop
According to the docs there are different ways to install and run the HomeGallery. I mixed two approaches (because it worked, you know): the tar-balls and a Docker image. The prebuilt binaries work perfectly fine for a quick check of the project but fail in the long run. They basically auto-extract the archive into some temporary directory and my OS removed some files while my image import was running. I avoided the issue by extracting the archive manually.
You can generate the default configuration and adjust it as needed. I tailored the one below for maximum privacy and easy deployment to the Raspberry Pi including adding new photos. You can generate a default config file with a built-in command.
The initial configuration file contains a lot of comments, so take a look. My local configuration looks as follows. All non-default values are highlighted.
In a nutshell this config places all data in the current working directory and does not transmit photos to any remote server which is not the case in the default configuration. Note that GPS data is transmitted to OpenStreetMap to translate them into addresses.
Initial photo import
Now you can add your photos by starting the local API server (first command) and starting the data import (second command). Among other things the import includes object detection, similarity analysis, thumbnail creation and GPS to address translation.
The import of roughly 20k photos on my MacBook took less than 24h. The gallery data on disk consumes a bit less then 25% of the disk space consumed by my photos (mostly JPEGs).
Installation on Raspberry Pi
As mentioned in a prior article my local Raspberry Pi already hosts an add-eating DNS. This device comes in handy in several ways for the gallery: there is already a running physical server, I have a local DNS to register LAN-wide domains and it already hosts a web-server.
Now let's co-locate the HomeGallery with the DNS and install it on the Raspberry Pi. I just "recycled" the OS X tar-ball and swapped the Node.js binaries.
Since directories are slightly different on the Raspberry we need a slightly different gallery.config.yml. This time I skip the commented lines.
Last thing to do is to upload the files and start the gallery. Note that starting a process with nohup has a lot of disadvantages over creating a service/daemon. The most important one: the gallery is not started at reboot which might be troublesome since I activated unattended upgrades. I still use nohup for now just to make it work for the first time. Please do not do this in a production environment!
Now you can already access the gallery via IP and port: http://192.168.12.34:3000 but let's register a domain at our DNS and use port 80.
Domain and virtual host
Thankfully the Pi-hole comes with a Web-UI hence already includes a web server named lighttpd. The Pi-hole developers made extending the lighttpd config possible such that Pi-hole updates to not revert the additional config (thank you so much for that!).
The web server support reverse-proxies (only for HTTP backends) and I found this snippet to start with. We need to add the following config.
If we make this the external config of the Pi-Hole setup, we are good to go. Just remember to register the domain fotos.lan in the Pi-hole web UI under Local DNS/DNS Records.
Enable TLD .lan in Firefox
Too late I realized that Firefox starts a web-search when I enter fotos.lan instead of opening the gallery. You can add .lan to the list of Top Level Domains in Firefox to fix this behavior. Just open about:config and set a new config entry browser.fixup.domainsuffixwhitelist.lan to true.
Adding new photos
As time passes by new photos become available, of course. You can add them to the gallery with the following commands. Only new files are processed.
As mentioned the gallery is a hobby project. Of course not everything is perfect. I still like it despite its rough edges. Some issues occurred though. If I find a solution I will add it here to this article. If you known a solution, please contact me.
- Some photos are indexed without object meta-data which excludes them from the similarity search.
- The executable bundles do not work, since a temporary directory is removed while the gallery is running.
How to Contribute
By using it: you can try it out yourself and tell others about it. This already helps the project. You can also report bugs.
By coding: feel free to fix some issues, update dependencies or implement something. The code is on GitHub and you can see the internals in docs. You may as well extend or fix the documentation.
By donation: This is from the original documentation: Do you like HomeGallery? Does it solve your media problem? Please support this project through any recurring support to my patreon.com/xemle or one time support to my paypal.me/xemle account. Thank you in advance.
Thank's for reading this far. As always feedback is highly welcome. Please feel free to contact me.