Skip to main content
Known Participant
5월 31, 2010 3:57 오전 UTC
공지사항

Is it possible to Change the Author of the image through Scripting?

I need to get the Author of the image through scripting. First i have to get the name of the Author which is already existing.And need to Rename the Author through script.  Its urgent requiremnt. pls help me out.

이 주제는 답변이 닫혔습니다.

1 답변

Paul Riggott
Inspiring
5월 31, 2010 4:08 오후 UTC

This example will read and put the Authors name to the ESTK console and write the new details back to the document.


#target bridge
loadXMPLibrary();
var thumb = app.document.selections[0];
if(thumb.hasMetadata){
        var selectedFile = thumb.spec;
  var myXmpFile = new XMPFile( selectedFile.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_UPDATE);
  var myXmp = myXmpFile.getXMP();   
  var arrItem='';
  var items = myXmp.countArrayItems(XMPConst.NS_DC, "creator");
   for(var i = 1;i <= items;i++){
arrItem += myXmp.getArrayItem(XMPConst.NS_DC,  "creator", i);          
        }   
    $.writeln(arrItem);
}
var Author = "This is my new Author";
myXmp.deleteProperty(XMPConst.NS_DC, "creator");
myXmp.appendArrayItem(XMPConst.NS_DC, "creator", Author, 0,XMPConst.ARRAY_IS_ORDERED);
if (myXmpFile.canPutXMP(myXmp)) {
    myXmpFile.putXMP(myXmp);
         myXmpFile.closeFile(XMPConst.CLOSE_UPDATE_SAFELY);
         }
unloadXMPLibrary();

function loadXMPLib(){
if (ExternalObject.AdobeXMPScript == undefined) {
    ExternalObject.AdobeXMPScript = new ExternalObject("lib:AdobeXMPScript");
}
}
function unloadXMPLib(){
   if( ExternalObject.AdobeXMPScript ) {
      try{
         ExternalObject.AdobeXMPScript.unload();
         ExternalObject.AdobeXMPScript = undefined;
      }catch (e){ }
   }
}

번역