From 700d8ef05a97da578ec90ff23b0d5f1b886264a5 Mon Sep 17 00:00:00 2001 From: Ein Anderssono Date: Mon, 15 Jun 2026 02:02:26 +0200 Subject: [PATCH] v0.8.5: add XMP privacy controls --- CHANGELOG.md | 9 ++++++++ Makefile | 2 +- README.md | 2 ++ RELEASE_NOTES.md | 13 ++++++------ USERGUIDE.md | 9 ++++++++ cmd/photoscli/main.go | 25 +++++++++++++++++++++-- cmd/photoscli/main_test.go | 42 ++++++++++++++++++++++++++++++++++++++ 7 files changed, 93 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a357f07..22c6306 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ This changelog is maintained from git history plus the published Gitea release series. Future releases should update this file and publish matching release notes on the release page. +## v0.8.5 + +XMP privacy controls release. + +- Add `--xmp-privacy keep|strip-location|strip-address` for generated sidecars. +- Keep existing XMP location/address behavior as the default with `keep`. +- Allow GPS coordinates to be kept while reverse-geocoded address fields are omitted with `strip-address`. +- Allow both GPS coordinates and address fields to be omitted with `strip-location`. + ## v0.8.4 Strict XMP sidecar verification release. diff --git a/Makefile b/Makefile index 46d9179..dd43600 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ BINARY := ./bin/photoscli MODULE := gitea.k3s.k0.nu/tools/photocli -VERSION := 0.8.4 +VERSION := 0.8.5 RELEASE_ZIP := ./bin/photoscli-$(VERSION)-macos-arm64.zip RELEASE_NOTES := RELEASE_NOTES.md BRIDGE_DIR := bridge diff --git a/README.md b/README.md index 37cb79e..30d198f 100644 --- a/README.md +++ b/README.md @@ -357,6 +357,8 @@ The XMP contains photoscli metadata such as asset ID, filenames, album, manifest Sidecars also include richer public PhotoKit metadata where available: modification date, duration, hidden state, adjustment state, media subtypes, source type, playback style, burst data, GPS coordinates, adjustment info, structured asset resources, standard XMP dates, EXIF GPS coordinates, favorite rating, and album/folder keywords. Add `--reverse-geocode` to include cached address fields from Apple MapKit for assets with GPS coordinates. Reverse geocoding requires macOS 26 or newer; on older macOS versions the export continues and XMP still includes GPS coordinates. +Control XMP location metadata with `--xmp-privacy keep|strip-location|strip-address`. The default is `keep`. Use `strip-address` to omit reverse-geocoded address fields while keeping GPS coordinates, or `strip-location` to omit both GPS and address fields. + Verify generated sidecars with: ```bash diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index bcf2551..3ec1f51 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,17 +1,18 @@ -# v0.8.4 +# v0.8.5 -This release adds strict XMP sidecar verification. +This release adds privacy controls for generated XMP sidecars. ## Highlights -- Add `verify --sidecar --strict` to require photoscli schema metadata, sidecar generator metadata, and matching exported filename metadata. -- Keep existing `verify --sidecar` behavior unchanged for basic sidecar checks. -- Use strict mode when validating sidecars generated by recent photoscli versions. +- Add `--xmp-privacy keep|strip-location|strip-address`. +- Keep existing behavior by default with `keep`. +- Use `strip-address` to omit reverse-geocoded address fields while keeping GPS coordinates. +- Use `strip-location` to omit both GPS coordinates and address fields. ## Assets - `photoscli`: Apple Silicon macOS binary (`darwin/arm64`). -- `photoscli-0.8.4-macos-arm64.zip`: Apple Silicon binary plus README, USERGUIDE, and CHANGELOG. +- `photoscli-0.8.5-macos-arm64.zip`: Apple Silicon binary plus README, USERGUIDE, and CHANGELOG. - `USERGUIDE.md`: standalone user guide. Intel Macs are not currently a supported release target. diff --git a/USERGUIDE.md b/USERGUIDE.md index 5386930..fbbf316 100644 --- a/USERGUIDE.md +++ b/USERGUIDE.md @@ -557,6 +557,15 @@ IMG_0001.HEIC -> IMG_0001.xmp The XMP includes photoscli archive metadata such as asset ID, original filename, exported filename, album, manifest path, media type, dimensions, favorite state, hidden state, cloud state, export mode, version, exported time, size, creation date, modification date, duration, adjustment state, media subtypes, source type, playback style, burst data, GPS coordinates, adjustment info, structured asset resources, standard XMP date fields, EXIF GPS fields, favorite rating, and album/folder keywords when PhotoKit exposes them. +Control location privacy in generated sidecars: + +```bash +./bin/photoscli export --album-id "Vacation" --out ./Vacation --sidecar xmp --xmp-privacy strip-address +./bin/photoscli export --album-id "Vacation" --out ./Vacation --sidecar xmp --xmp-privacy strip-location +``` + +`keep` is the default. `strip-address` omits reverse-geocoded address fields while preserving GPS coordinates. `strip-location` omits both GPS coordinates and address fields. + For address metadata from GPS coordinates, opt in to Apple's reverse geocoder: ```bash diff --git a/cmd/photoscli/main.go b/cmd/photoscli/main.go index 9be6dc8..4e41752 100644 --- a/cmd/photoscli/main.go +++ b/cmd/photoscli/main.go @@ -42,6 +42,7 @@ type exportOptions struct { verify bool format string sidecar string + xmpPrivacy string metadataOnly bool reverseGeocode bool minSize int64 @@ -229,6 +230,9 @@ COMMON EXPORT FLAGS Write opt-in XMP sidecar metadata next to each exported file. Default: none. If XMP writing fails, the asset is counted as failed. + --xmp-privacy keep|strip-location|strip-address + Control location/address metadata in generated XMP sidecars. Default: keep. + --metadata-only With --sidecar xmp, write or refresh XMP sidecars for files already in the manifest without exporting media files. Requires a manifest. @@ -1091,10 +1095,22 @@ func writeSidecarIfNeeded(pa pendingAsset, result photos.ExportResult, originals if pa.asset.ModificationDate != nil { modifyDate = *pa.asset.ModificationDate } + location := pa.asset.Location + xmpPrivacy := opts.xmpPrivacy + if xmpPrivacy == "" { + xmpPrivacy = "keep" + } var placemark *photos.Placemark - if opts.reverseGeocode && pa.asset.Location != nil && cache != nil { + if opts.reverseGeocode && location != nil && cache != nil && xmpPrivacy == "keep" { placemark = cache.lookup(pa.asset.Location.Latitude, pa.asset.Location.Longitude, bridge) } + if xmpPrivacy == "strip-location" { + location = nil + placemark = nil + } + if xmpPrivacy == "strip-address" { + placemark = nil + } return writeXMPSidecar(sidecarPath(fullPath), xmpSidecarData{ AssetID: pa.asset.ID, OriginalFilename: pa.asset.Filename, @@ -1120,7 +1136,7 @@ func writeSidecarIfNeeded(pa pendingAsset, result photos.ExportResult, originals Size: result.Size, CreateDate: createDate, ModifyDate: modifyDate, - Location: pa.asset.Location, + Location: location, Placemark: placemark, BurstIdentifier: pa.asset.BurstIdentifier, RepresentsBurst: pa.asset.RepresentsBurst, @@ -1875,6 +1891,7 @@ func parseExportOptions(args []string, stderr io.Writer) (exportOptions, bool) { verify: hasFlag(args, "--verify"), format: flagValWithDefault(args, "--format", "jpeg"), sidecar: flagValWithDefault(args, "--sidecar", "none"), + xmpPrivacy: flagValWithDefault(args, "--xmp-privacy", "keep"), metadataOnly: hasFlag(args, "--metadata-only"), reverseGeocode: hasFlag(args, "--reverse-geocode"), dateTemplate: flagVal(args, "--date-template"), @@ -1891,6 +1908,10 @@ func parseExportOptions(args []string, stderr io.Writer) (exportOptions, bool) { fmt.Fprintf(stderr, "error: --sidecar must be none or xmp, got %q\n", opts.sidecar) return opts, false } + if opts.xmpPrivacy != "keep" && opts.xmpPrivacy != "strip-location" && opts.xmpPrivacy != "strip-address" { + fmt.Fprintf(stderr, "error: --xmp-privacy must be keep, strip-location, or strip-address, got %q\n", opts.xmpPrivacy) + return opts, false + } if opts.metadataOnly && opts.sidecar != "xmp" { fmt.Fprintln(stderr, "error: --metadata-only requires --sidecar xmp") return opts, false diff --git a/cmd/photoscli/main_test.go b/cmd/photoscli/main_test.go index 3fbce66..4c5da85 100644 --- a/cmd/photoscli/main_test.go +++ b/cmd/photoscli/main_test.go @@ -4584,6 +4584,10 @@ func TestSidecarConfigAndErrors(t *testing.T) { if _, ok := parseExportOptions([]string{"--sidecar", "bad"}, &stderr); ok || !strings.Contains(stderr.String(), "--sidecar") { t.Fatalf("expected sidecar validation error, stderr=%q", stderr.String()) } + stderr.Reset() + if _, ok := parseExportOptions([]string{"--xmp-privacy", "bad"}, &stderr); ok || !strings.Contains(stderr.String(), "--xmp-privacy") { + t.Fatalf("expected xmp privacy validation error, stderr=%q", stderr.String()) + } b := &mockBridge{assets: []photos.Asset{{ID: "x1", Filename: "photo.jpg"}}} b.exportPreviewFn = func(assetID, out string, targetSize, quality, index int) (photos.ExportResult, error) { @@ -4598,6 +4602,44 @@ func TestSidecarConfigAndErrors(t *testing.T) { } } +func TestXMPSidecarPrivacy(t *testing.T) { + dir := t.TempDir() + asset := photos.Asset{ID: "x1", Filename: "geo.jpg", Location: &photos.AssetLocation{Latitude: 59.3293, Longitude: 18.0686}} + bridge := &mockBridge{} + bridge.reverseGeocodeFn = func(float64, float64) (photos.Placemark, error) { + return photos.Placemark{Country: "Sweden", Locality: "Stockholm"}, nil + } + pa := pendingAsset{asset: asset, root: dir, path: dir, album: "Album"} + for _, tc := range []struct { + privacy string + wantGPS bool + wantAddress bool + }{ + {privacy: "keep", wantGPS: true, wantAddress: true}, + {privacy: "strip-address", wantGPS: true, wantAddress: false}, + {privacy: "strip-location", wantGPS: false, wantAddress: false}, + } { + path := filepath.Join(dir, tc.privacy+".jpg") + if err := os.WriteFile(path, []byte("data"), 0644); err != nil { + t.Fatal(err) + } + if err := writeSidecarIfNeeded(pa, photos.ExportResult{Filename: filepath.Base(path), Size: 4}, false, exportOptions{sidecar: "xmp", reverseGeocode: true, xmpPrivacy: tc.privacy}, newGeocodeCache(dir), bridge); err != nil { + t.Fatalf("%s write sidecar: %v", tc.privacy, err) + } + data, err := os.ReadFile(sidecarPath(path)) + if err != nil { + t.Fatal(err) + } + content := string(data) + if strings.Contains(content, "photoscli:latitude") != tc.wantGPS { + t.Fatalf("%s GPS presence mismatch in %s", tc.privacy, content) + } + if strings.Contains(content, "photoscli:addressCountry") != tc.wantAddress { + t.Fatalf("%s address presence mismatch in %s", tc.privacy, content) + } + } +} + func TestMetadataOnlyExport(t *testing.T) { dir := t.TempDir() m := manifest.LoadJSONL(dir)