2 Replies Latest reply on Sep 4, 2015 3:43 AM by hemantk12546598

    After Effects reading XMP image data via scripting

    tims96209324 Level 1

      I've been trying to get the code below to work and it keeps throwing an error "Undefined is not an object."

      if (ExternalObject.AdobeXMPScript == undefined) {
          ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
      }
      var metaFile = File.openDialog("Select file to import");
      var xmpFile = new XMPFile(metaFile.fsName, XMPConst.FILE_UNKNOWN, XMPConst.OPEN_FOR_READ);
      var xmp = xmpFile.getXMP();
      alert(xmp.getProperty(XMPConst.NS_TIFF, "Model").toString()); //throws error "Undefined is not an object"
      xmpFile.closeFile();
      metaFile.close();
      


      Is there something key missing or that I don't understand?

      FYI - I know that the data is there to read as I can see it using the "File Info..." command in Photoshop.


      Also looking for help and information or good resources to learn more about scripting After Effects to read XMP image information.

      I've read the XMP sections in the Extendscript Javascript Tools Guide and I am still struggling with accessing the info via AE scripting.

      Any help/pointers would be greatly appreciated.

        • 1. Re: After Effects reading XMP image data via scripting
          tims96209324 Level 1

          So this is embarrassing...

           

          Seams that after a rebooting and running this script again this morning (in Australia) it's working.

          Something must have been stuck in memory somewhere because I ran this exact same script yesterday on the same file and it threw back undefined every single time. Even after restarting AE and Extendscript multiple times.

           

          Now it's returning the camera model like it's suppose to.

           

          Rather annoying waste of time but at least the script works!

           

          Hope it helps someone else out there.

          • 2. Re: After Effects reading XMP image data via scripting
            hemantk12546598 Level 1

            hiii tims96209324 , i am also trying to do something like this but facing the same problem it will be great if you could help me out with this,

            I have imported a .png file to my AE project i want to write some xmp metadata into it,and also want to read the same metadata when required.....this script is not working for me .....is their any other way to do this.I used the script but after restarting also it is giving me the same error "Undefined is not an object".
            Do i need to define struture field of xmp like this
            xmp.setStructField("kAEFTPrivateProjectMetadataURI","Thumbnails","kAEFTPrivateProjectMeta dataURI:", 0,null );

            but this is also giving me an error " namespaceURI is not defined"
            here is my code to set metadata in my .png file

            var metaFile = app.project.item(CWFileIndex).file; 
            var xmpFile = new XMPFile(metaFile.fsName, XMPConst.FILE_UNKNOWN, XMPConst.OPEN_FOR_READ); 
            var xmp = xmpFile.getXMP(); 
            XMPMeta.registerNamespace("http://ns.adobe.com/premierePrivateProjectMetaData/1.0/", "kAEFTPrivateProjectMetadataURI");
            var obj = xmp.dumpObject();
            var namespaces = XMPMeta.dumpNamespaces();
            var projectIdToWrite = "CW" + CWProjectId;
            xmp.setProperty(kAEFTPrivateProjectMetadataURI, cwprojectidfield, projectIdToWrite);
            metaFile = xmp.serialize();

            and the code for getting meta data is

            for (var i = 1; i <= noOfChildren; i++) {

              if (app.project.item(i) instanceof FootageItem) {

                    if(app.project.item(i).file.name == CWFileName){

             

              result["cwindex"] = i;

              var metaFile = app.project.item(i).file; 

              var xmpFile = new XMPFile(metaFile.fsName, XMPConst.FILE_UNKNOWN, XMPConst.OPEN_FOR_READ); 

              var xmp = xmpFile.getXMP(); 

              XMPMeta.registerNamespace("http://ns.adobe.com/premierePrivateProjectMetaData/1.0/", "kAEFTPrivateProjectMetadataURI");

              // xmp.setStructField("kAEFTPrivateProjectMetadataURI","Thumbnails","kAEFTPrivateProjectMeta dataURI:", 0,null );

              try{

              var desc = xmp.getProperty(kAEFTPrivateProjectMetadataURI, "cwprojectidfield").value; //throws error "Undefined is not an object"

              if (desc.substr(0, 2) == "CW") {

              result["CWProjectId"] = desc.substr(2);

              cachedProjectID=result["CWProjectId"];

              }

              }

              catch(e){

              return result;

              }

             

              xmpFile.closeFile(); 

              metaFile.close(); 

             

              }

              return result;

                }

            }
            i don't know what i am doing wrong.