【Adobe Premiere Pro脚本开发】如何从PPro项目中提取图像尺寸

main();

/*
    https://community.adobe.com/t5/premiere-pro/how-to-extract-image-dimensions-from-a-ppro-projectitem/td-p/12000680
    如何从PPro项目中提取图像尺寸
    */
 function main(){
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);

			}
		}
	}
}


}

 

你可能感兴趣的:(#,Premiere,Pro脚本开发)