AppleScript: Get Image Location Data I am trying to write an Automator Script which involves, among other things, getting the GPS location data from an image. This will be a Finder Service.

From what I have been able to discover so far, it involves running some AppleScript and talking to the Image Events headless application.

From here, how do I actually get the Latitude &amp; Longitude of the image?

I know there are applications which can read this data, including on the command line, but I wondered whether it was available to MacOS without adding anything.
I do not believe Image Events is able to get that type of meta data from the photo however mdls can do it, e.g. mdls -name kMDItemLatitude -name kMDItemLongitude /path/to/photo however it all depends what exactly your trying to do with this info. I personally prefer using exiftool however you'd have to install it.

To answer the question in your comment:

If you query an attributeName when using -raw and the attributeName doesn't exist the output is literally (null) and if you want it to be something else then use −nullMarker markerString, e.g.: −nullMarker "Does Not Exist"

mdls -name kMDItemFake -raw -nullMarker "Does Not Exist" /path/to/photo


In the example command above kMDItemFake is a fake kMDItem item, so that command will output: Does Not Exist instead of (null).

In other words, if as example the photo doesn't have kMDItemLatitude info and you query for it the output will be (null) when using mdls -name kMDItemLatitude -raw. To change that, use −nullMarker markerString.

If a kMDItem doesn't exist and you want no output when using mdls -name attar -raw then use mdls -name attar -raw −nullMarker '' /path/to/photo.