#441 In the desktop app, a photo's moment shows its thumbnail (#440)
–
- github
- github/openchronology/timeline-app
- github/openchronology/timeline-app#441
- pull request
- state:merged
Closes #440. In the desktop app, a moment whose source is a photo on this computer now shows a small picture of that photo as its marker, so a timeline made from a photo folder reads like an album. ## How it works - **Plugin:** the new official **File thumbnails** plugin (`file-thumbnails`) adds a marker kind, `{ "kind": "file-thumbnail", "metadataKey": "sources" }`. It marks a moment with its first source that is a `file:///` link to a photo, checked by extension (`localPhoto`). The file populator installs it with Sources. It has no fields and only affects moments. - **Showing it:** `imageSource()` maps a `file:` link through a function the desktop registers (`useLocalImages`), and to nothing elsewhere. So the existing marker, stack-card and hover code all show thumbnails unchanged. - The editor gathers the photos the markers need into batches of up to 64. - It asks Rust for them (`desktop_thumbnails`), keeps the latest 2,000 in memory, and redraws when they arrive. - **Making it (`src-tauri/src/thumbnails.rs`):** - It uses the photo's own EXIF preview when there is one: IFD1's JPEG, read from a JPEG's APP1 segment or from the start of a TIFF-based raw file. - Otherwise it decodes and scales the photo with the `image` crate (JPEG, PNG, WebP, TIFF, GIF, BMP), with limits on size and memory. - The picture is turned upright by the EXIF orientation, shrunk (never enlarged) to at most 160 px, and encoded as a JPEG at quality 80. - It's kept in the app's cache folder under a hash of the path, size and modification time, written to a temporary file and then renamed, and returned as a `data:` URL. - One request makes up to 64 thumbnails, on 4 threads. - **Content policy:** the desktop's rules already allow `data:` images, so there's no asset protocol and no new scope. - **Safety:** Rust makes thumbnails only of regular files with a photo's extension (`populate::kind`). Thumbnails are never written into the document or sent anywhere. The `file:` links themselves are still removed before anything goes to a server, as in #439. ## What isn't covered - **Videos and sound** show no picture. Getting a frame without ffmpeg is still an open question; filed as #442. - **HEIC, AVIF and raw files** show a thumbnail only when they carry their own JPEG preview. - **Cache size:** the cache isn't trimmed. Thumbnails are about 5–10 KB each, and deleting the folder only means they're made again. ## Tests - **Rust (10 tests, run locally; 2 new):** - a wide PNG is scaled to 160×80; - a JPEG with an embedded thumbnail and orientation 6 uses the blue embedded picture, not the red photo, and stands upright; - the cache is reused, and a new thumbnail is made after the file changes; - text files, broken JPEGs, folders, missing files, HTTPS links and links to other computers are refused. - **Unit tests:** `localPhoto`, the plugin's marker and its projection, and validating the manifest. The plugin catalogue's page order is updated. All 435 pass. - **Browser test:** `test/populate-browser.mjs` checks that the photo's marker shows the thumbnail Rust returns, that only the photo is asked for (not the video), and that the template installs File thumbnails. It passes in the Playwright image. - **Not tested here:** the real desktop app wasn't clicked through, since there's no display. Docs: a Thumbnails section in `docs/file-populator.md`, File thumbnails in `docs/plugins.md` and the guide, and `THIRD_PARTY.md` (image, base64). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_011fFY8eruEi1xAkkMBni13B https://github.com/openchronology/timeline-app/pull/441
Related
- #439 The desktop makes timelines from files, each opening in its own app (#433)
- #440 Desktop: thumbnails for moments made from photos and videos
- #442 Desktop: thumbnails for videos, and for HEIC and AVIF photos without a preview
- Merge pull request #441 from openchronology/feature/440-file-thumbnails
Open #441 In the desktop app, a photo's moment shows its thumbnail (#440) in the timeline