3 Replies Latest reply on Feb 7, 2010 6:58 PM by Todd_Kopriva

    Writing XMP Thumbnail Metadata to AE Preset (Scripting)

    AthorNZ

      Hi guys.

       


      I am working on a script to basically insert a gif as metadata into a fx preset file. If you open Adobe bridge and browse to the After effects text presets you will see that you can click on a preset and in the preview there is an animated GIF. So I am attempting to do this for custom presets.

       

      Basically I think I need to read the contents of a GIF file as data, or text, then encode that as base64 and insert it into the metadata of the preset file.

       

      I have a come across a couple of problems though:

       

      1) I can't seem to read in the GIF file as data

       

           The code I am using is:

       

      file = new File("C:\\test.gif");
      file.open("r");
      test = file.read();
      alert(test);

       

      And all I get returned is the first part of the data which is "GIF89aØ", It seems that when white space is encountered After Effects stops reading the data.

       

      2) I have been testing some code to write thumbnail data to a preset file, but I have come across an issue here too.

       

      if (ExternalObject.AdobeXMPScript == undefined) {
      ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
      }
      xmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);

       

      file = new File("C:\\joshPreset.ffx");
      xmpFile = new XMPFile(file.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);

      var xmp = xmpFile.getXMP();

      xmp.appendArrayItem( "http://ns.adobe.com/xap/1.0/","Thumbnails",null, 0,XMPConst.ARRAY_IS_ALTERNATIVE );

       

      This code works, it inserts a Thumbnails array into the metadata, which looks like this:

       


         <xmp:Thumbnails>
          <rdf:Alt>
          </rdf:Alt>
         </xmp:Thumbnails>

       

       

      I then need to add other properties within the Thumbnails array like xapGImg:height and xapGImg:image

       

      So from what I read in the documentation I need to add a Struct field?

       

      I add these lines to my code:

       

      XMPMeta.registerNamespace("http://ns.adobe.com/xap/1.0/g/img/", "xapGImg");
      xmp.setStructField("xapGImg","Thumbnails","xapGImg:height", 0,null );

       

      The first line is to register the name space. xapGImg is what I found in the after effects text preset file.

      The second line is to add a struct field to the array. But I get an error whenever I run it with the second line. It says:

       

      XMP Exception: Unregistered schema namespace URI

       

      I have tried all different combinations of the namespace in the second line but just cannot get it to work!

       

      If anyone can help that would be great!