Voting in der Community ⬆️⬇️

Wenn euch Beiträge von anderen Usern gefallen, könnt ihr dies durch eine positive Bewertung zeigen und wenn ihr angemeldet seid, so sogar Punkte vergeben. Erfahrt hier mehr zu unserem Bewertungssystem: Voting in der deutschen Apple Support Community


Script: Kopiere GPS Koordinaten von einem Foto zu anderen Fotos, Version für 2019

von: 
Zuletzt geändert: 22. März 2019 13:57
2 874 Zuletzt geändert 22. März 2019 13:57

Diese Version ersetzt Script: Kopiere GPS Koordinaten von einem… - Apple Community

In Yosemite und El Capitan waren die GPS Koordinaten nicht mit einem Apple Script modifizierbar, aber das hat sich in macOS Sierra geändert. Wir können nun ein Apple Script verwenden, um die GPS EXIF tags für geographische Breite und Länge eines Fotos zu ändern.

Laut des Apple Script Lexikons für Fotos sollten wir auch die GPS Höhe verändern können, aber wenn ich das versuche, gibt es zur Zeit noch eine Fehlermeldung.

Aber immerhin, wir können jetzt die Breite und Länge von einem Foto kopieren und die Länge und Breite ausgewählter Fotos auf dieselben Werte setzen.


Das folgende AppleScript ist ein Beispiel, wie wir GPS in ein Foto schreiben können:

Es wird wie folgt verwendet:


  • In Fotos für Mac erzeuge ein Album mit den Fotos, die neue GPS Werte bekommen sollen.
  • Dann füge das Foto zu dem Album hinzu, von dem die GPS Werte kopiert werden sollen. Dieses Foto muss das erste Foto im Album sein und gleich am Anfang stehen.
  • Dann wähle alle Fotos im Album aus: Zuerst das Foto, das als Kopiervorlage dienen soll, dann halte den Shift-Taste (Umschalttaste) runter und wähle das letzte Foto aus.
  • Jetzt öffne das Script in Script Editor und drücke den Run Knopf.


Danach sollten alle ausgewählten Fotos denselben Ort nach Breite und Länge haben.

Aber teste dieses zuerst mit einer kleinen Test-Mediathek und nicht in der eigenen Mediathek. Ich würde auch immer eine neue Sicherheitskopie anlegen, bevor ich ein Script auf der Mediathek laufen lasse.


Hier kommt das Script - alles zwischen den gestrichelten Linien:

------------------- ✂︎ schnipp ab hier ✂︎ -------------------

(* Batch copy GPS from first photo to all other selected photos
How to use  this script:
- Collect all photos you want to set to the same GPS coordinates  in an album and sort them manually
- The first photo should have a GPS location assigned
- Select first the photo with the correct location, the hold down the Shift key and select all photos you want to set to the same location at once. You need to select at least two photos.
- Open this script and run it by pressing the "Run" button.
- The script will copy the location from the first image and set all photos to the same location

- if you save this script as an Application you can add it to the Dock and run it from there


This script has been tested in Photos version 2.0 to to Photos 4.0, with MacOS X 10.12.2 to macOS 10.14.3

© Léonie
*)


(* select at least 2 images in Photos *)
tell application "Photos"
	activate
	set imageSel to (get selection)
	if (imageSel is {}) or (the length of imageSel < 2) then
		error "Please select at least two images."
	else
		set withAlti to false
		set withLati to false
		set withLongi to false
		
		try
			tell the first item of imageSel
				set loc to get the location --retrieve longitude and latitude as list
				set alti to get the altitude -- retrieve the altitude
				
				set lati to (the first item of loc) -- as number
				set longi to (the second item of loc) -- as number
				
				--		return altiS
				set withAlti to (alti is not equal to missing value)
				set withLati to (lati is not equal to missing value)
				set withLongi to (longi is not equal to missing value)
				
				if not withLati then
					set withLati to false
					error "Photo has no Latitude assigned"
				end if
				
				if not withLongi then
					error "Photo has no Latitude assigned"
				end if
				if (lati > 90.0) or (lati < -90.0) then
					error "Latitude out of range " & lati
				end if
				if (longi > 180.0) or (longi < -180.0) then
					error "Longitude out of range " & longi
				end if
				
			end tell
		on error errTexttwo number errNumtwo
			display dialog "No GPS: " & errNumtwo & return & errTexttwo
			return
		end try
		
		if (not withLongi or not withLati) then
			
			return {loc, alti} --testing
		end if
		
		repeat with i from 2 to count of imageSel
			
			set next_image to item i of imageSel
			
			tell next_image
				set its location to {lati, longi}
				if withAlti then -- photo has altitude tag
					-- set its altitude to alti as number -- does not work
				end if
			end tell
			
			
		end repeat
	end if
	
	return {loc, alti, "Done"} -- for testing
end tell

------------------- ✂︎ schnipp bis hier ✂︎ -------------------

Willkommen in der Apple Support Community
Ein Forum, in dem Apple-Kunden sich gegenseitig mit ihren Produkten helfen. Melde dich mit deiner Apple-ID an, um Mitglied zu werden.