Copy link to clipboard
Copied
Hi guys,
I'm batch editing all jpeg files metadata. I achieve to edit XMP title,description, keyword of jpeg files. But I want to edit IPTC data of these jpeg files too. Because shutterstock reads metadata from IPTC. So is it possible to edit IPTC description, keyword with extendscript in Illustrator ? if possible how ?
I attached sample jpeg IPTC below. Just I want to copy XMP metadata to suitable IPTC metada.
Any help appreciated ! Thanks !
Copy link to clipboard
Copied
Here's a function which I dug up from a long time ago which reads only the description string:
function ReadXMPviaLibrary(targetFile){
if(ExternalObject.AdobeXMPScript == undefined) {
ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
}
var fNm = targetFile, obj;
var xmp = new XMPFile( fNm.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ);
obj = xmp.getXMP();
xmp.closeFile();
var descriptionString = "";
try{
descriptionString = obj.getLocalizedText(XMPConst.NS_DC, "description", null, "en");
return descriptionString;
} catch(e){
return null;
}
};
Ten_A is the local master of all things XMP:
Re: Script to copy variables into metadata
And here's one where Ten_A also adds more code regarding this topic:
Hopefully you can edit the functions to accomplishyour goal!
Copy link to clipboard
Copied
You can add below method after getXMP() in Silly-V's code. You'll see some IPTC info in ESTK console.
$.write(obj.dumpObject());
Copy link to clipboard
Copied
Silly-V​ @Ten A, thank you for your responses. These are so helpful.
But I want to edit IPTC info with ExtendScript. Because shutterstock reads IPTC data, not XMP data. I want to copy XMP to IPTC and save it.
Copy link to clipboard
Copied
As far as I know, It is all inside XMP data. I am wondering if shutterstock is simply reading the IPTC fields inside the XMP data?
Copy link to clipboard
Copied
Here is a sample dump of metadata.
Dumping XMPMeta object "" (0x0)
dc: http://purl.org/dc/elements/1.1/ (0x80000000 : schema)
dc:format = "application/pdf"
dc:title (0x1E00 : isLangAlt isAlt isOrdered isArray)
[1] = "iptcTest" (0x50 : hasLang hasQual)
? xml:lang = "x-default" (0x20 : isQual)
dc:creator (0x600 : isOrdered isArray)
[1] = "ten"
xmp: http://ns.adobe.com/xap/1.0/ (0x80000000 : schema)
xmp:MetadataDate = "2018-02-05T08:37:32+09:00"
xmp:ModifyDate = "2018-02-05T08:37:32+09:00"
xmp:CreateDate = "2018-02-05T08:37:32+09:00"
xmp:CreatorTool = "Adobe Illustrator CC 2017 (Macintosh)"
xmp:Thumbnails (0xE00 : isAlt isOrdered isArray)
[1] (0x100 : isStruct)
xmpGImg:width = "256"
xmpGImg:height = "256"
xmpGImg:format = "JPEG"
xmpGImg:image = "/9j/4AAQSkZJRgABAgEASABIAAD/7QAsUGhvdG9zaG9wIDMuMAA4QklNA+0AAAAAABAASAAAAAEA
AQBIAAAAAQAB/+4ADkFkb2JlAGTAAAAAAf/bAIQABgQEBAUEBgUFBgkGBQYJCwgGBggLDAoKCwoK
......
xmpG:swatchName = "C=60 M=90 Y=0 K=0"
xmpG:mode = "CMYK"
xmpG:type = "PROCESS"
xmpG:cyan = "60.000000"
xmpG:magenta = "90.000000"
xmpG:yellow = "0.003100"
xmpG:black = "0.003100"
pdf: http://ns.adobe.com/pdf/1.3/ (0x80000000 : schema)
pdf:Producer = "Adobe PDF library 15.00"
Iptc4xmpCore: http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/ (0x80000000 : schema)
Iptc4xmpCore:CreatorContactInfo (0x100 : isStruct)
Iptc4xmpCore:CiAdrExtadr = "Wakayama, Japan"
"http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/ " is namespace of the IPTC meta, We need to use when we access the IPTC metadata.
Copy link to clipboard
Copied
I used dumpObject just now to get a sense of the way color plate names are recorded inside this data.
Fortunately, it really helped, and extra googling yielded the correct XMPConst enumeration to read this information too:
And now I have a function which gets a file's plates just like this!
function getPlateNamesFromXMP(targetFile){
if(ExternalObject.AdobeXMPScript == undefined) {
ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
}
var fNm = targetFile, obj;
var xmp = new XMPFile( fNm.fsName, XMPConst.UNKNOWN, XMPConst.OPEN_FOR_READ);
obj = xmp.getXMP();
xmp.closeFile();
var metaString = "";
try{
var plateNames = [];
var plateNameAmt = obj.countArrayItems(XMPConst.TYPE_PAGEDFILE, "PlateNames");
for (var i = 0; i < plateNameAmt; i++) {
plateNames.push(obj.getArrayItem(XMPConst.TYPE_PAGEDFILE, "PlateNames", (i + 1)));
}
return plateNames;
} catch(e){
return null;
}
};