我有一个Photoshop脚本将文件名添加为文本图层(没有扩展名),然后重新定位它并更改字体大小。除了字体大小外,它一切都很完美 - 它默认为50px。
var docRef = activeDocument;
// Now create a text layer at the front
var myLayerRef = docRef.artLayers.add();
myLayerRef.kind = LayerKind.TEXT;
myLayerRef.name = "Filename";
var myTextRef = myLayerRef.textItem;
// strip the extension off
var fileNameNoExtension = docRef.name;
fileNameNoExtension = fileNameNoExtension.split( "." );
if ( fileNameNoExtension.length > 1 ) {
fileNameNoExtension.length--;
}
fileNameNoExtension = fileNameNoExtension.join(".");
myTextRef.contents = fileNameNoExtension.substring(0);
// off set the text to be in the middle
myTextRef.position = new Array( "279", "641");
myTextRef.size = new UnitValue(20, 'px');
如果删除最后一行,则文本默认为12px。我还尝试用以下代码替换最后一行:
myTextRef.size = new UnitValue("20", "px");
myTextRef.size = "20";
myTextRef.size = 20;
myTextRef.size = "20 px";
myTextRef.size = 20px;