1 Reply Latest reply on Jun 29, 2015 12:29 PM by S Hopkins

    Location Autotext  is not functioning without external script?

    emcgillivray

      I am looking to use the Location autotext function built into indesign. It should be pulling the location from the metadata from a photo that is underneath or grouped to a text box that the autotext is located in. The autotext will pull over all the rest of the metadata including shutter, aperture, ISO. But will not pull over the GPS coordinates that are attached in the XMP sidecar file to the photo. Support has informed me that is requires an additional script to use the location metadata. Now I am looking of the script to make this function or some info around what the location autotext is looking to reference so that I can write my own script?

        • 1. Re: Location Autotext  is not functioning without external script?
          S Hopkins Adobe Community Professional

          Hi,

          Thank your friend Preran Kumar for alerting me to your post.

          Yes, this needs an external script. The problem is that Adobe has not exposed all of the metadata that can be found on a file for Autotext--although they have exposed a great deal more than we get with script access (link XMP). I tried to see if there was any way we could modify what Adobe provides InDesign--and maybe there is, but I could not find it. So, here is the solution. You can use either Bridge or Photoshop to get the XMP properties that you want. The code below uses Photoshop to expose the GPSLatitude and GPSLongitude. The example below is working with a JPEG file, but should work with other formats. I am not sure what your workflow is but I would suggest using doScript from InDesign to run a javascript similar to the following to get the GPS coordinates.

          For more information about XMP see Adobe's JavaScriptToolsGuideCC_.pdf. Also, I will be making this a subject of my blog for this week. Look for it later in the week at www.yourscriptdoctor.com/blogs. To test the following out, change the value of filePath to the path to a JPEG file on your computer and run from ExtendScript. The result will be posted in ExtendScript's JavaScript Console. Hope this does it for you.

           

          #target "Photoshop"

          //arguments is being passed to the script from a doScript command in InDesign.

          var filePath = arguments[0].toString();

          var fileRef = new File(filePath);

          //load XMP library

          if (ExternalObject.AdobeXMPScript == undefined){

              ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');

          }

          if (fileRef instanceof File) {

                 var xmpf = new XMPFile (fileRef.fsName, XMPConst.NS_PHOTOSHOP,     XMPConst.OPEN_FOR_READ);

                 var xmp = xmpf.getXMP();

                 xmpf.closeFile()

                 var myLat = xmp.getProperty(XMPConst.NS_EXIF, "GPSLatitude").toString();

                 var myLong = xmp.getProperty(XMPConst.NS_EXIF, "GPSLongitude").toString();

                 var myString = myLat + ", " + myLong;

          } else {

                 alert ("Not a file");

          }

          myString;