Copy link to clipboard
Copied
Hello all!
Thanks to an interesting question from a PPro scripter, I've written some example PPro ExtendScript that extracts the dimensions of a projectItem.
var kPProPrivateProjectMetadataURI = "http://ns.adobe.com/premierePrivateProjectMetaData/1.0/";
if (ExternalObject.AdobeXMPScript === undefined) {
ExternalObject.AdobeXMPScript = new ExternalObject('lib:AdobeXMPScript');
}
var firstItemInProject = app.project.rootItem.children[0]; // make sure first item is media.
if (firstItemInProject) {
var projectMetadata = firstItemInProject.getProjectMetadata();
if (projectMetadata) {
var projectMetadataAsXMP = new XMPMeta(projectMetadata);
if (projectMetadataAsXMP) {
var dimensionsFieldName = "Column.Intrinsic.VideoInfo";
var dimensionsInfo = projectMetadataAsXMP.getProperty(kPProPrivateProjectMetadataURI, dimensionsFieldName);
if (dimensionsInfo) {
var widthArray = [];
var heightArray = [];
var dimensionsVal = dimensionsInfo.value;
var widthEndPos = dimensionsVal.indexOf(" ");
var heightStartPos = (dimensionsVal.indexOf("x") + 2);
var heightEndPos = dimensionsVal.indexOf("(") - 1;
for (var a = 0; a < widthEndPos; a++) {
widthArray[a] = dimensionsVal[a];
}
for (var b = 0; b < (heightEndPos - heightStartPos); b++) {
heightArray[b] = dimensionsVal[b + heightStartPos]; // offset to start of height, within source dimension value.
}
var widthAsString = widthArray.join(""); // turn the array into a string, with no separator characters
var heightAsString = heightArray.join("");
var width = parseInt(widthAsString); // turn the string into an int.
var height = parseInt(heightAsString);
}
}
}
}
Copy link to clipboard
Copied
Thanks, exactly what I was looking for!
The last part could be written like this as well (much simpler):
if (dimensionsInfo) {
var val = dimensionsInfo.value;
var mid = val.indexOf("x");
var width = parseInt(val.substr(0, mid));
var height = parseInt(val.substr(mid + 1));
}