0

I want to be able to view a location embedded in a HEIC file quickly by using 'quick action'.

It is how it looks like when I tried to use the function via finder.

enter image description here

Here is the definition of the quick action in Automator.

enter image description here

However when I run the quick action, I got this error message "Automator could not convert the input data to the desired type."

enter image description here

What does it mean and how can I fix it?

2

The Show Location in Maps action in Automator takes a Photos Media Item as input, not a Finder item.

In other words, it could be used in conjunction with a Get Selected Photos Item action, but not as the first action in a Automator Service/Quick Action that is set as Workflow receives current [image files] in [Finder].

Have look at: The “Show Location in Maps” Action

enter image description here



Update to address comment:

Is there any other way I can retrieve the map location and then show it in the Map app?

Here is one way to accomplish the goal...

The following example AppleScript code was tested in a Run AppleScript action in an Automator Service/Quick Action under macOS Catalina and worked for me without any issues:

on run {input, parameters}
    
    set imageFile to the quoted form of ¬
        the POSIX path of (the first item of input)
    
    set shellCMD to {"mdls -name kMDItemLatitude -name kMDItemLongitude ", ¬
        imageFile, " | awk '{print $NF}'"} as string
    
    set LatLon to paragraphs of (do shell script shellCMD)
    
    if (LatLon as string) contains "null" then return
    
    set latitude to first item of LatLon
    set longitude to second item of LatLon
    set mapsLocation to {"https://maps.apple.com/?ll=", ¬
        latitude, ",", longitude} as string
    
    open location mapsLocation
    tell application "Maps" to activate
    delay 0.5
    tell application "System Events" to ¬
        keystroke "D" using {shift down, command down}
    
end run

Notes:

  • As currently coded it only works with one selected image file in Finder. Additional coding is required if want to act on multiple selected image files in Finder.
  • As currently coded, if a selected image file in Finder does not contain meta data for kMDItemLatitude and kMDItemLongitude for mdls to output, then the script stops without any feedback. If you what to be notified, then additional coding is required.


enter image description here



Note: The example AppleScript code is just that and sans any included error handling does not contain any additional error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors. Additionally, the use of the delay command may be necessary between events where appropriate, e.g. delay 0.5, with the value of the delay set appropriately.

2
  • Is there any other way I can retrieve the map location and then show it in the Map app? – Anthony Kong Apr 10 at 23:54
  • @Anthony Kong, Regarding your comment, please see the Update to address comment: section of the updated answer. – user3439894 Apr 11 at 3:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .