v0.8.5: add XMP privacy controls
This commit is contained in:
+23
-2
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user