Simple static photo gallery that groups images by year and person. Demo
index.html— the web UI that readsphotos.jsonand displays the gallery.createjson.js— Node.js script to generatephotos.jsonfrom a folder tree of photos.
createjson.js scans a root folder that contains subfolders named by year (for example 2020, 2021) and builds a photos.json file. The main page (index.html) loads that JSON to render a browsable gallery.
Requirements: Node.js (v14+ recommended).
Examples:
# Default: embed images as file paths in the JSON
node createjson.js --root "C:\path\to\photos-root" --out photos.json
# Embed images as Base64
node createjson.js --root "C:\path\to\photos-root" --out photos.json --embed
# Produce a compact JSON (no pretty formatting)
node createjson.js --root "C:\path\to\photos-root" --out photos.json --compact--root/-r: root folder containing year subfolders.--out/-o: output JSON path.--embed/-e: embed images as base64.--compact/-c: write compact JSON.
The script also tries to extract person names from filenames (e.g. maria_dad.jpg → ['Maria','Dad']). If no names are found it uses Unknown.
- Opening
index.htmldirectly may work in some browsers (json is loaded via javascript so it's blocked), but a simple static server is recommended. - You may replace
json = await fetch('photos.json').then(r=>r.json());in your html to include your image data in your html, fixing the previous point. - This project does NOT provide encryption, authentication, or password protection. If you serve it on a public server or share the files, anyone who can access the server or the JSON can view all the images and data.