Co-Authored-By: Claude Opus 5.5 <[email protected]>
LuPhoto
LuPhoto serves photos.luciochen.com. It is one Go program that reads album folders, cuts every photo into 512 px WebP tiles at several resolutions with libvips, and publishes a static site in which the browser stitches the visible tiles back together on a canvas. Design: docs/DESIGN.md.
Commands
luphoto [-config /etc/luphoto/config.toml] <command>
| Command | What it does |
|---|---|
build |
Process the albums once, publish a new build, exit. |
serve |
Build, watch the albums folder, rebuild after changes, and serve the site over HTTP on server.listen. |
export |
Build, watch and rebuild; no HTTP. Point Caddy or nginx at <output>/current. |
run |
serve or export, whichever server.mode says. The systemd unit uses this. |
version |
Print the version. |
A missing config file means all defaults. SIGHUP re-reads the config and rebuilds (an invalid config is logged and the old one kept; a new server.listen restarts the listener). SIGINT/SIGTERM stop gracefully. Rebuilds never overlap; changes during a build cause one follow-up build.
Album folders
/srv/luphoto/albums/
2026-10-iceland/
album.json
DSC_0001.jpg
PANO_0007.jpg
The folder name is the album slug (/a/2026-10-iceland/). Only JPEGs listed in album.json are processed and shown. An album whose album.json is broken is skipped and logged; if the previous build had it, that version stays live.
{
"title": "Iceland, in October",
"subtitle": "冰岛 · 十月",
"date": "2026-10",
"order": 10,
"hidden": false,
"cover": { "photo": "PANO_0007.jpg", "crop": [0, 410, 8256, 2322] },
"collapsed_focus_y": 0.5,
"show_exif": true,
"photos": [
{ "file": "DSC_0001.jpg", "title": "Vík", "caption": "Black sand, *7 a.m.*", "alt": "A black sand beach" },
{ "file": "PANO_0007.jpg", "caption": "Two screens wide", "slides": 2 }
]
}
| Field | Type | Default | Meaning |
|---|---|---|---|
title |
string | folder name | Album title, sentence case. |
subtitle |
string | none | Second line, for example the Chinese title. |
date |
YYYY, YYYY-MM or YYYY-MM-DD |
none | Shown as the eyebrow; sorts albums without order, newest first. |
order |
integer | none | Albums with order come first, ascending. |
hidden |
bool | false |
Built and reachable by URL, but left off the index. |
cover.photo |
file name | first photo | Photo the 32:9 cover is cut from. Must be listed in photos. |
cover.crop |
[x, y, w, h] |
none | Cover rectangle in pixels of the upright photo. |
cover.focus_y |
0–1 | 0.5 | Without crop: a 32:9 band at full width centred at this height. |
collapsed_focus_y |
0–1 | 0.5 | Which 32:6 band of the cover a closed index strip shows. |
show_exif |
bool | true |
Put camera, lens, focal length, aperture, shutter, ISO and date into the manifest and caption line. GPS is never kept. |
photos[].file |
file name | required | A .jpg/.jpeg in the album folder. Order of the list is the viewing order. |
photos[].title |
string | none | Caption title. |
photos[].caption |
string | none | Plain text; *emphasis* and line breaks only. |
photos[].alt |
string | none | Text alternative for screen readers. |
photos[].slides |
integer ≥ 1 | 1 | Show a wide photo as N viewport-wide sections with a continuous pan. |
Unknown fields are errors, so typos are caught.
Config
/etc/luphoto/config.toml; every key is optional. packaging/config.toml is the production file.
| Key | Default | Meaning |
|---|---|---|
server.mode |
"export" |
What luphoto run does: "serve" or "export". |
server.listen |
"127.0.0.1:8080" |
Address of the built-in HTTP server. |
server.base_url |
"https://photos.luciochen.com" |
Used for canonical and Open Graph URLs. |
paths.albums |
"/srv/luphoto/albums" |
Album folders. Read only. |
paths.output |
root or systemd: /var/lib/luphoto/site, else $XDG_DATA_HOME/luphoto/site |
Builds, tiles, current. The site key and per-photo records go to state/ next to it. |
paths.cache |
root or systemd: /var/cache/luphoto, else the user cache dir |
Temporary vips files. |
images.tile_size |
512 |
Tile edge in pixels. |
images.overlap |
1 |
Tile overlap in pixels. |
images.format |
"webp" |
"webp" or "avif" (AVIF needs a libheif AV1 encoder). |
images.quality |
{ top = 82, mid = 85, low = 88 } |
Top two levels, levels above 1100 px, levels up to 1100 px. |
images.min_levels |
6 |
Minimum pyramid depth. |
images.seed_px |
48 |
Long edge of the blurred placeholder. |
images.tile_names |
"hashed" |
Only "hashed" in v1. |
images.scramble_cells |
false |
Shuffle the 64 px cells inside each tile with a per-photo key; the browser restores them when it decodes a tile. Forces tile overlap 0. Changing it reprocesses everything. |
loading.budget_ms |
3000 |
Time budget per photo in the browser. |
loading.max_dpr |
2.0 |
Highest device pixel ratio the loader honours. |
loading.concurrency |
6 |
Parallel tile requests. |
build.watch |
true |
Watch the albums folder in serve and export. |
build.debounce |
"30s" |
Quiet time after the last change before rebuilding. |
build.workers |
2 |
Photos processed in parallel. vips threads per photo = CPUs ÷ workers. |
build.keep_builds |
3 |
Builds kept; tiles no kept build uses are deleted. |
protection.block_context_menu |
true |
Disable the context menu on photos. |
protection.hotlink_allow |
["photos.luciochen.com"] |
Hosts allowed as Referer for /t/*; empty Referers and the site's own host are always allowed. |
The watcher ignores dotfiles (including rsync's .name.XXXXXX temp files), *.part, *.tmp and editor backups. vips runs at nice +5 so processing does not starve the web server.
Install
Ubuntu 22.04 / 24.04, Debian 12
sudo apt install ./luphoto_<version>_amd64.deb
sudoedit /etc/luphoto/config.toml
sudo systemctl enable --now luphoto
The package depends on libvips-tools and creates:
- user and group
luphoto, and groupluphoto-upload; /srv/luphoto/albums(root:luphoto-upload, mode 2775, so members ofluphoto-uploadcan upload);/var/lib/luphotoand/var/cache/luphoto(owned byluphoto);/etc/luphoto/config.toml(kept on upgrade),/usr/lib/systemd/system/luphoto.service, and examples in/usr/share/doc/luphoto/.
The unit runs luphoto run as luphoto with ProtectSystem=strict, the albums read only, and only /var/lib/luphoto and /var/cache/luphoto writable. systemctl reload luphoto sends SIGHUP.
Other distributions
Unpack luphoto_<version>_linux_<arch>.tar.gz and follow its INSTALL.md. You need libvips 8.12+ with its command-line tools.
Uploading
Add yourself to luphoto-upload (sudo usermod -aG luphoto-upload $USER, then log in again), then:
rsync -av --chmod=Dg+rwxs,Fg+rw 2026-10-iceland/ server:/srv/luphoto/albums/2026-10-iceland/
rsync writes to dotted temp names and renames at the end, which the watcher ignores; the rebuild starts build.debounce after the last file lands. SFTP clients that upload to *.part work the same way.
Web server
- Serve mode: LuPhoto serves
currentitself with the right headers (immutable caching for/t/,/og/,/assets/; one minute for HTML and JSON; CSP; hotlink 403 on/t/*; precompressed gzip; no directory listings;404.htmlfor missing paths). Put Caddy (packaging/Caddyfile.serve), nginx (packaging/nginx.serve.conf) or a Cloudflare Tunnel in front. - Export mode: serve
/var/lib/luphoto/site/currentwithpackaging/Caddyfileorpackaging/nginx.conf. Each build writes.gzfiles next to HTML, JSON, JS, CSS and SVG forprecompressed gzip/gzip_static. - Cloudflare:
packaging/cloudflared.ymlandpackaging/cloudflare.md(cache rules).
Building from source
Development runs in Docker; the Windows host needs no libvips. From Git Bash or any POSIX shell:
scripts/dev.sh go build -o bin/luphoto ./cmd/luphoto
scripts/dev.sh go vet ./...
scripts/dev.sh
scripts/dev.sh builds the luphoto-dev image (Ubuntu 24.04, Go, libvips-tools) on first use, mounts the repository at /src and keeps Go caches in volumes. Extra docker run arguments go in LUPHOTO_DEV_ARGS, for example LUPHOTO_DEV_ARGS="-v /path/to/work:/work -p 127.0.0.1:8080:8080".
scripts/package.sh builds static binaries (CGO_ENABLED=0, -trimpath, -ldflags "-s -w -X main.version=…") for amd64 and arm64, the .deb packages (nfpm, installed into .tools/ on first use) and the tarballs into dist/, all inside the dev container. Set VERSION to override git describe. The Makefile has web, build, dist and deb targets for hosts with make.
Front-end
TypeScript and CSS live in web/src. The minified bundles, fonts, favicon and chop in internal/site/static are committed, so go build never needs Node. After changing the front-end, rebuild on a host with Node 22:
npm --prefix web ci
npm --prefix web run build
This type-checks with tsc --noEmit (strict) and bundles with esbuild. Fonts are self-hosted from the @fontsource packages (latin and latin-ext only). Each site build writes the files to /assets/ under content-hashed names.
Brand
scripts/sync-brand.sh copies the tokens, lucio-morph.js, the favicon and the chop from ../LUCIO_ip (or $LUCIO_IP_DIR) into web/brand/, stripping comments. The copies are committed; rebuild the front-end afterwards.
Output layout
/var/lib/luphoto/
site/
current -> builds/<id>
builds/<id>/index.html, 404.html, index.<id>.json, a/<slug>/index.html, a/<slug>/manifest.<id>.json, assets/, t -> ../../t, og -> ../../og (plus .gz copies)
t/<photo-hash>/<tile-id>.webp
og/<hash>.jpg
state/
site.key
pyramids/<photo-hash>.json