Kasper Peeters kasper.peeters@phi-sci.com
Licensed under the GPL.
WARNING This is not yet feature-complete
Shotweb is a simple, modern and compact C++ server for Linux to share Shotwell [https://wiki.gnome.org/Apps/Shotwell] photo albums via the web. I have a large collection of photos and videos which I do not want to store in a cloud service, but still want to share with friends and family. The master copy lives on my laptop and is categorised/labelled with Shotwell. I thus simply wanted to share individual Shotwell events with other people. Because I could not find anything suitable (most photo sharing server software, such as Piwigo or Nextcloud, is far to complex while still not serving my basic needs), I decided to write one myself.
Features:
- Serve directly from the shotwell database and photo folders.
- Photos as well as videos.
- Multiple user accounts.
- Each user can be given access to individual events.
- Events can be shared by sending a link with a token, does not require guest to register an account.
- Generates thumbnails for photos and videos on the fly.
- Thumbnail caching.
- Clean compact C++ with handcoded HTML/CSS/JS.
In the pipeline:
- Photo pre-loading for quick browsing.
- Download single photos or entire events as zip files.
There are a few related projects, mostly unmaintained, which inspired Shotweb::
- [http://www.jonh.net/~jonh/shotgo/README.html]
- [https://github.com/vmassuchetto/shotwell-web-client/tree/master/shotwell_web_client]
These are instructions for Debian/Ubuntu, adjust the build prerequisites appropriately for other distros. First install the prerequisites with::
sudo apt install cmake g++ libopencv-dev libboost-all-dev \
libsqlite3-dev libscrypt-dev ffmpegthumbnailer
You need a fairly decent C++ compiler, so on e.g. Ubuntu 18.04 you will need to install clang and then do e.g.::
export CXX=/usr/bin/clang++-7
export CC=/usr/bin/clang-7
With gcc 7.4.0 (and possibly others) you will get errors about
std::experimental::optional<T>
.
Make sure you checkout the git submodules:
cd shotweb
git submodule update --init --recursive
Then build and install with::
cd shotweb
mkdir build
cd build
cmake ..
make
sudo make install
Run the shotweb server with::
shotweb [path-to-config-file]
The configuration file is a JSON file with the following content::
{
"photo.db": "/path/to/photo.db",
"auth.db": "/path/to/auth.db",
"html_css_js_dir": "/usr/local/share/shotweb/",
"thumb_cache_dir": "/path/to/thumbnails/",
"old_root": "",
"new_root": "",
"port": 8123,
"title": "title of your gallery"
}
The meaning of the parameters is::
-
photo.db:
The full path to the 'photo.db' database, as generated by Shotwell. Use a copy if you can.
-
auth.db:
The full path of the authentication database file 'auth.db'. Can be empty on start, in which case the first access to shotweb will ask for a new admin name and password.
-
html_css_js_dir:
The directory in which the HTML/CSS/JS files are stored. This is typically '/usr/local/share/shotweb/' or similar.
-
thumb_cache_dir:
A path where shotweb will cache thumbnail images. You can re-use the thumbnails produced by shotwell if you want, in which case you should set this to something like
`${HOME}/.cache/shotwell/thumbs/thumbs360/`
-
old_root:
-
new_root:
If the location of the pictures on the shotweb server is not the same as the location of the pictures on your shotwell installation, shotweb needs to rewrite the paths in
photo.db
in order to find the picture files. Theold_root
andnew_root
settings are respectively the root of the picture storage on your shotwell setup, and the root of the picture storage on your shotweb server. You could have e.g::"old_root": "/home/user/Pictures/", "new_root": "/var/shotweb/pictures/"
-
port:
The IP port on which to run the server. If you want to run it over https, the best idea is to run it behind an apache or nginx web server and let that one proxy the connection to shotweb.
Once the server is running, you can access the site and setup your administrator password (do this immediately!).
Shotweb will automatically convert all videos so they adapt to the available bandwidth of the viewer, using HLS; see
[https://www.exoscale.com/syslog/self-hosted-videos/]
for more info. This uses the video2hls
script taken from
[https://github.com/vincentbernat/video2hls]
Video conversion is triggered by the shotweb server automatically, and it keeps a queue of videos to convert.
WARNING: This is a new feature; if you click on a video the conversion will start in the background, but you will need to reload the event page (after the conversion has completed) to be able to view the video.
-
OpenCV [https://opencv.org] For image manipulation and photo/video thumbnail generation.
-
sqlite_modern_cpp [https://github.com/SqliteModernCpp/sqlite_modern_cpp] Used to access e.g. shotwell's sqlite database.
-
nlohmann/json [https://github.com/nlohmann/json] For json manipulation.
-
httplib.h [https://github.com/yhirose/cpp-httplib] For web server functionality.
-
miniz-cpp [https://github.com/tfussell/miniz-cpp.git] To create zip files.