Automating Ubuntu Screenshots to Google Photos
Description and use
Automatically uploads Ubuntu screenshots to Google Photos, preserving accurate capture time and timezone, without altering original files.
Problem
Ubuntu screenshots lack accurate capture timestamps when uploaded to Google Photos, causing incorrect date metadata.
Outcome
Automated pipeline uploads Ubuntu screenshots to Google Photos with accurate capture timestamps and timezone, preserving original files and preventing manual uploads.
Workflow
- Create project directory and virtualenv
- Install required Python packages
- Set up Google Cloud OAuth credentials and store client_secret.json
- Run auth.py to obtain and store token.json
- Configure inotify to watch ~/Pictures/GooglePhotos/upload/ for new PNGs
- On new file, use GNU stat to read birth time
- Embed DateTimeOriginal and timezone into PNG via Pillow
- Upload image bytes to Google Photos API (upload token + batchCreate)
- Move uploaded file to ~/Pictures/GooglePhotos/uploaded/
Evidence
The original screenshot is never modified.
Google Photos uses a two‑step upload process: Image bytes → POST /v1/uploads → Upload token → POST /v1/mediaItems:batchCreate → Google Photos media item
- Record date: 2026-09-20T08:16:47.987Z