all the small things:[程序设计]PS脚本应用--读Exif信息给相片加边框[附完整源代码]
来源:百度文库 编辑:中财网 时间:2024/04/28 23:58:48
*/
//------------- Main script Begin ------------
var colorErr = "边框灰度值输入错误!" + "\n" + "系统将默认为黑色。";
var noLens = ’<不显示镜头信息>’;
var titleColor = new SolidColor(); //主题文字颜色
var msgColor = new SolidColor(); //说明文字颜色
var infoColor = new SolidColor(); //拍摄信息文字颜色
var titleFontColor; //主题颜色名称
var msgFontColor; //说明文字颜色名称
var infoFontColor; //拍摄信息颜色名称
var colors = new Array(); //颜色值数组
var colorNames = new Array(); //颜色名称数组
var frameSide = 1; //文字的位置代码。1为下面,2为右面,3为左面
//读取系统字体,定义字体名称及PostScript name of the font
var myFonts = new Array();
var fontPSNames = new Array();
for (i = 0;i < fonts.length;i ++)
{
if (! fontPSNames[fonts[i].family])
{
fontPSNames[fonts[i].family] = fonts[i].postScriptName;
myFonts.push(fonts[i].family);
}
}
var builder = createBuilderDialog(); //定义对话框内容
initializeBuilder(builder); //初始化状态值
if (runBuilder(builder) == 1)
{
var resSpec = createFrame(builder); //创建边框
}
//------------- Main script End -------------
//定义设置对话框 开始
function createBuilderDialog()
{
var myFontSizes = new Array(); //定义字体字号
myFontSizes[0] = 10;
myFontSizes[1] = 12;
myFontSizes[2] = 14;
myFontSizes[3] = 16;
myFontSizes[4] = 20;
myFontSizes[5] = 24;
myFontSizes[6] = 32;
var myLens = new Array(); //定义镜头。请自行修改为自己所拥有的镜头型号
myLens[0] = noLens; //请不要改动该行
myLens[1] = ’SIGMA AF 18-125mm F3.5-5.6 DC’;
myLens[2] = ’CANON EF 50mm F/1.8Ⅱ’;
//设置对话框界面文字内容
var optionTitle = ’相片边框信息设置[Build 20050820]’;
var msgPnlTitle = ’输入信息’;
var titleDescription = ’相片主题’;
var titleEditText = ’<请输入相片主题>’;
var fontSizeDescription = ’字号’;
var fontDescription = ’字体’;
var msgDescription = ’说明文字’;
var msgEditText = ’<请输入相片说明文字>’;
var lensDescription = ’拍摄信息’;
var frameWidthDescription = ’边框宽度’;
var frameWidthRadiobutton1 = ’宽边’;
var frameWidthRadiobutton2 = ’窄边’;
var frameColorDescription = ’ 边框灰度’;
var frameColorNote = ’(0为黑色,255为白色)’;
var labelSideDescription = ’标签位置’;
var labelSideText0 = ’自动’;
var labelSideText1 = ’下边’;
var labelSideText2 = ’右边’;
var labelSideText3 = ’左边’;
var labelSideNote = ’(自动:横幅时为下边,竖幅时为右边)’;
var okDescription = ’确定’;
var cancelDescription = ’取消’;
var colorDescription = ’颜色’;
//定义颜色名称及颜色值。用户可以改为自己喜欢的颜色
colorNames[0] = ’黑色’;
colors[colorNames[0]] = [0,0,0];
colorNames[1] = ’白色’;
colors[colorNames[1]] = [255,255,255];
colorNames[2] = ’褐色’;
colors[colorNames[2]] = [165,42,42];
colorNames[3] = ’金色’;
colors[colorNames[3]] = [255,215,0];
colorNames[4] = ’灰色’;
colors[colorNames[4]] = [128,128,128];
colorNames[5] = ’亮灰色’;
colors[colorNames[5]] = [211,211,211];
colorNames[6] = ’暗灰色’;
colors[colorNames[6]] = [169,169,169];
colorNames[7] = ’绿色’;
colors[colorNames[7]] = [0,128,0];
colorNames[8] = ’浅绿色’;
colors[colorNames[8]] = [0,255,255];
colorNames[9] = ’栗色’;
colors[colorNames[9]] = [128,0,0];
colorNames[10] = ’橙色’;
colors[colorNames[10]] = [255,165,0];
colorNames[11] = ’橄榄色’;
colors[colorNames[11]] = [128,128,0];
colorNames[12] = ’紫色’;
colors[colorNames[12]] = [128,0,128];
colorNames[13] = ’红色’;
colors[colorNames[13]] = [255,0,0];
colorNames[14] = ’银色’;
colors[colorNames[14]] = [192,192,192];
colorNames[15] = ’黄色’;
colors[colorNames[15]] = [255,255,0];
colorNames[16] = ’淡黄色’;
colors[colorNames[16]] = [245,222,179];
colorNames[17] = ’蓝色’;
colors[colorNames[17]] = [0,0,255];
colorNames[18] = ’暗蓝色’;
colors[colorNames[18]] = [0,0,139];
colorNames[19] = ’青色’;
colors[colorNames[19]] = [0,255,255];
colorNames[20] = ’茶色’;
colors[colorNames[20]] = [210,180,140];
var dlg = new Window(’dialog’, optionTitle);
//建立设置区面板。
dlg.msgPnl = dlg.add(’panel’, undefined, msgPnlTitle);
dlg.msgPnl.alignChildren = "left";
dlg.msgPnl.orientation = "column";
//有个不解的问题,移动调整代码行顺序,可获得不同的行间间隔。行间间隔是由dropdownlist产生的
dlg.msgPnl.titleFont = dlg.msgPnl.add(’group’); //主题字体
dlg.msgPnl.titleFontSize = dlg.msgPnl.add(’group’); //主体字号
dlg.msgPnl.title = dlg.msgPnl.add(’group’); //主题
dlg.msgPnl.msg = dlg.msgPnl.add(’group’); //说明文字
dlg.msgPnl.lens = dlg.msgPnl.add(’group’); //镜头型号
dlg.msgPnl.infoFont = dlg.msgPnl.add(’group’); //拍摄信息字体
dlg.msgPnl.infoFontSize = dlg.msgPnl.add(’group’); //拍摄信息字号
dlg.msgPnl.frameWidthh = dlg.msgPnl.add(’group’); //边框宽度
dlg.msgPnl.frameColor = dlg.msgPnl.add(’group’); //边框灰度
dlg.msgPnl.labelSide = dlg.msgPnl.add(’group’); //文字位置
dlg.msgPnl.msgFont = dlg.msgPnl.add(’group’); //说明文字字体
dlg.msgPnl.msgFontSize = dlg.msgPnl.add(’group’); //说明文字字号
dlg.msgPnl.titleColors = dlg.msgPnl.add(’group’); //主题文字颜色
dlg.msgPnl.msgColors = dlg.msgPnl.add(’group’); //说明文字颜色
dlg.msgPnl.infoColors = dlg.msgPnl.add(’group’); //拍摄信息颜色
with (dlg.msgPnl)
{
alignChildren = ’fill’;
title.st = title.add(’statictext’, undefined, titleDescription);
title.et = title.add(’edittext’, undefined, titleEditText,{multiline:false});
title.et.preferredSize = [200,20];
msg.st = msg.add(’statictext’, undefined, msgDescription);
msg.et = msg.add(’edittext’, undefined, msgEditText,{multiline:false});
msg.et.preferredSize = [200,20];
lens.st = lens.add(’statictext’, undefined, lensDescription);
lens.et = lens.add(’dropdownlist’, undefined, myLens);
lens.et.selection = 0; //指定镜头型号默认值索引数。从0开始计数。
lens.et.preferredSize = [200,20];
infoFontSize.st = lens.add(’statictext’, undefined, fontSizeDescription);
infoFontSize.et = lens.add(’dropdownlist’, undefined, myFontSizes);
infoFontSize.et.selection = 2; //指定拍摄信息字号默认值索引数。从0开始计数。
infoFontSize.et.preferredSize = [40,20];
infoFont.st = lens.add(’statictext’, undefined, fontDescription);
infoFont.et = lens.add(’dropdownlist’, undefined, myFonts);
infoFont.et.selection = 8; //指定拍摄信息字体默认值索引数。从0开始计数。
//infoFont.et.preferredSize = [140,20];
titleFontSize.st = title.add(’statictext’, undefined, fontSizeDescription);
titleFontSize.et = title.add(’dropdownlist’, undefined, myFontSizes);
titleFontSize.et.selection = 4; //指定主题字号默认值索引数。从0开始计数。
titleFontSize.et.preferredSize = [40,20];
msgFontSize.st = msg.add(’statictext’, undefined, fontSizeDescription);
msgFontSize.et = msg.add(’dropdownlist’, undefined, myFontSizes);
msgFontSize.et.selection = 2; //指定说明文字字号默认值索引数。从0开始计数。
msgFontSize.et.preferredSize = [40,20];
titleFont.st = title.add(’statictext’, undefined, fontDescription);
titleFont.et = title.add(’dropdownlist’, undefined, myFonts);
titleFont.et.selection = 5; //指定主题文字字体默认值索引数。从0开始计数。
//titleFont.et.preferredSize = [140,20];
msgFont.st = msg.add(’statictext’, undefined, fontDescription);
msgFont.et = msg.add(’dropdownlist’, undefined, myFonts);
msgFont.et.selection = 10; //指定说明文字字体默认值索引数。从0开始计数。
//msgFont.et.preferredSize = [140,20];
frameWidthh.st = frameWidthh.add(’statictext’, undefined, frameWidthDescription);
frameWidthh.frameWidth1 = frameWidthh.add(’radiobutton’, undefined, frameWidthRadiobutton1);
frameWidthh.frameWidth2 = frameWidthh.add(’radiobutton’, undefined, frameWidthRadiobutton2);
frameColor.st = frameWidthh.add(’statictext’, undefined, frameColorDescription);
frameColor.sl = frameWidthh.add(’slider’, undefined, 0, 0, 255); //中间的0为初始化值
frameColor.sl.preferredSize = [180, 20];
frameColor.et = frameWidthh.add(’edittext’);
frameColor.et.preferredSize = [40, 20];
frameColor.st = frameWidthh.add(’statictext’, undefined, frameColorNote);
labelSide.st = labelSide.add(’statictext’, undefined, labelSideDescription);
labelSide.labelSide0 = labelSide.add(’radiobutton’, undefined, labelSideText0);
labelSide.labelSide1 = labelSide.add(’radiobutton’, undefined, labelSideText1);
labelSide.labelSide2 = labelSide.add(’radiobutton’, undefined, labelSideText2);
labelSide.labelSide3 = labelSide.add(’radiobutton’, undefined, labelSideText3);
labelSide.st = labelSide.add(’statictext’, undefined, labelSideNote);
titleColors.st = title.add(’statictext’, undefined, colorDescription);
titleColors.et = title.add(’dropdownlist’, undefined, colorNames);
titleColors.et.selection = 3; //指定主题文字颜色默认值索引数。从0开始计数。
//titleColors.et.preferredSize = [60,20];
msgColors.st = msg.add(’statictext’, undefined, colorDescription);
msgColors.et = msg.add(’dropdownlist’, undefined, colorNames);
msgColors.et.selection = 1; //指定说明文字颜色默认值索引数。从0开始计数。
//msgColors.et.preferredSize = [60,20];
infoColors.st = lens.add(’statictext’, undefined, colorDescription);
infoColors.et = lens.add(’dropdownlist’, undefined, colorNames);
infoColors.et.selection = 1; //指定拍摄信息文字颜色默认值索引数。从0开始计数。
//infoColors.et.preferredSize = [60,20];
}
//建立按钮面板
dlg.btnPnl = dlg.add(’group’);
dlg.btnPnl.orientation = "row";
dlg.btnPnl.okBtn = dlg.btnPnl.add(’button’, undefined, okDescription, {name:’ok’});
dlg.btnPnl.cancelBtn = dlg.btnPnl.add(’button’, undefined, cancelDescription, {name:’cancel’});
dlg.center(); //设置对话框为屏幕中心位置
return dlg;
} // 定义设置对话框 结束
// Set up initial control states
// 初始化设置区信息
function initializeBuilder(builder)
{
with (builder)
{
btnPnl.okBtn.onClick = function () { this.parent.parent.close(1);};
btnPnl.cancelBtn.onClick = function () { this.parent.parent.close(2);};
with (msgPnl)
{
frameColor.et.text = frameColor.sl.value;
frameColor.et.onChange = function () { this.parent.parent.frameColor.sl.value = this.text; };
frameColor.sl.onChanging = function () { this.parent.parent.frameColor.et.text = parseInt(this.value); };
frameWidthh.frameWidth1.value = true; //边框默认值为宽边
//frameWidthh.frameWidth2.value = true; //边框默认值为窄边
labelSide.labelSide0.value = true; //标签位置默认值为自动
}
}
}
// This function invokes the dialog an returns its result
// 调用并返回对话框的结果
function runBuilder(builder)
{
return builder.show();
}
//分解Exif信息中的字符串。该获取Exif信息的方法引用于互联网上。
//本人觉得该方法不是太好,效率低,应该从XML格式文件中直接提取相关元素信息
function explodeArray(item) {
var i=0;
var Count=0;
var tempString=new String(item);
tempArray=new Array(1);
do{
i=tempString.indexOf(":");
if(i>0)
tempString=tempString.substr(i+1,tempString.length-i-1);
i=tempString.indexOf(">");
if(i>0) {
tempArray[Count]=tempString.substr(0,i);
tempString=tempString.substr(i+1,tempString.length-i-1);
Count ++;
}
i=tempString.indexOf("<");
if(i>0) {
tempArray[Count]=tempString.substr(0,i);
tempString=tempString.substr(i-1,tempString.length-i+1);
Count ++;
}
}while (tempString.indexOf("")>0);
tempArray[Count]=tempString;
return tempArray;
}
//生成相片边框动作
function createFrame(builder)
{
//AD = activeDocument; //在原相片上添加边框
var AD = activeDocument.duplicate(); //在相片的副本上添加边框
var photoWidth = AD.width.value; //图片宽度
var photoHeight = AD.height.value; //图片高度
if (photoWidth < photoHeight) //如果图片高度大于宽度则选择右侧标注文字
frameSide = 2;
if (builder.msgPnl.labelSide.labelSide1.value) //选择下侧标注文字
frameSide = 1;
if (builder.msgPnl.labelSide.labelSide2.value) //选择右侧标注文字
frameSide = 2;
if (builder.msgPnl.labelSide.labelSide3.value) //选择左侧标注文字
frameSide = 3;
switch (frameSide)
{
case 2:
app.activeDocument.rotateCanvas(90.0); //如果选择右侧标注文字则90度旋转
break;
case 3:
app.activeDocument.rotateCanvas(-90.0); //如果选择左侧标注文字则-90度旋转
break;
}
var title = builder.msgPnl.title.et.text; //获取相片主题
var body = builder.msgPnl.msg.et.text; //获取说明文字
var lens = builder.msgPnl.lens.et.selection.text; //获取镜头型号
var lFontSize = builder.msgPnl.titleFontSize.et.selection.text; //获取主题字号
var rFontSize = builder.msgPnl.msgFontSize.et.selection.text; //获取说明文字字号
var frameC = parseInt(builder.msgPnl.frameColor.sl.value); //获取边框灰度值
var infoFontSize = builder.msgPnl.infoFontSize.et.selection.text; //获取拍摄信息字号
var infoHeight = 0 //拍摄信息高度调整
titleFontColor = builder.msgPnl.titleColors.et.selection.text; //获取主题颜色名称
msgFontColor = builder.msgPnl.msgColors.et.selection.text; //获取说明文字颜色名称
infoFontColor = builder.msgPnl.infoColors.et.selection.text; //获取拍摄信息颜色名称
titleColor.rgb.red = colors[titleFontColor][0];
titleColor.rgb.green = colors[titleFontColor][1];
titleColor.rgb.blue = colors[titleFontColor][2];
msgColor.rgb.red = colors[msgFontColor][0];
msgColor.rgb.green = colors[msgFontColor][1];
msgColor.rgb.blue = colors[msgFontColor][2];
infoColor.rgb.red = colors[infoFontColor][0];
infoColor.rgb.green = colors[infoFontColor][1];
infoColor.rgb.blue = colors[infoFontColor][2];
if (body != ’’)
{
infoHeight = 20
}
if(frameC != frameC + 0)
{
Window.alert(colorErr);
frameC = 0;
}
if (lens != noLens)
{lens = builder.msgPnl.lens.et.selection.text;}
else
{lens = ’’;}
//宽边时参数
var fLong = 1/10; //边框宽度与相片宽度的倍数
//窄边时参数
if (builder.msgPnl.frameWidthh.frameWidth2.value)
{
fLong = 1/40;
}
var kColor = new SolidColor(); //框底色。通过滑杆赋值
var fColor = new SolidColor(); //内边线色。或者黑或者白
var rColor = new SolidColor(); //右边字体颜色。或者黑或者白
//初始化为黑色边框
kColor.rgb.red = kColor.rgb.green = kColor.rgb.blue = 0;
fColor.rgb.red = fColor.rgb.green = fColor.rgb.blue = 255;
rColor.rgb.red = rColor.rgb.green = rColor.rgb.blue = 255;
//如果frameC不等于0,则为灰色或白色边框
if (frameC != 0)
{
kColor.rgb.red = kColor.rgb.green = kColor.rgb.blue = frameC;
fColor.rgb.red = fColor.rgb.green = fColor.rgb.blue = 255 - frameC;
rColor.rgb.red = rColor.rgb.green = rColor.rgb.blue = 0;
}
var defaultRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
var resRatio = AD.resolution/72;
if(resRatio != 1)
{
AD.resizeImage(AD.width.value,AD.height.value,72);
}
//定义参数
photoWidth = AD.width.value; //图片宽度
photoHeight = AD.height.value; //图片高度
var wFrame = AD.width.value + 2; //内框边线的宽度,单边实际宽度需除以2
var hFrame = AD.height.value + 2; //内框边线的高度,单边实际高度需除以2
var fWidth = parseInt(photoWidth*fLong); //边框底的宽度,单边实际宽度需除以2。
var fHeight = parseInt(photoWidth*fLong); //边框底的高度,单边实际高度需除以2。
//获取RAW相片保存的Exif信息
var exifData = AD.xmpMetadata.rawData.toString();
/*
//该工具提取相片的Exif完整信息为XML文件,并保存在c:\Exif.xml
var exifFileName = "c:\\Exif.xml";
var file = new File(exifFileName);
file.open(’w’);
file.writeln(exifData);
file.close();
alert("It has been written to " + exifFileName);
*/
//将EXIF信息分成单个的相关信息
explodeArray(exifData);
var exposureTime = ""; //快门
var fNumber = ""; //光圈
var ISOSpeedRatings = ""; //ISO设置
var dateTimeOriginal = ""; //相片拍摄时间
var phoDate = ""; //拍摄日期
var phoTime = ""; //拍摄时间
var i = 0;
var j = 0;
var k = 0;
var dateArray1 = "";
var dateArray2 = "";
//快门速度
for(n = 0; n < tempArray.length; n ++)
{
stringTemp = tempArray[n];
if(stringTemp.indexOf("ExposureTime") != -1)
{
exposureTime = tempArray[n+1];
break;
}
}
//光圈大小
for(n = 0; n < tempArray.length; n ++)
{
stringTemp = tempArray[n];
if(stringTemp.indexOf("FNumber") != -1)
{
fNumber = tempArray[n+1];
break;
}
}
//拍摄日期、时间
for(n = 0; n < tempArray.length; n ++)
{
stringTemp = tempArray[n];
if(stringTemp.indexOf("DateTimeOriginal") != -1)
{
dateTimeOriginal = tempArray[n+1];
break;
}
}
//ISO设置
for(n = 0; n < tempArray.length; n ++)
{
stringTemp = tempArray[n];
if(stringTemp.indexOf("ISOSpeedRatings") != -1)
{
ISOSpeedRatings = "ISO" + tempArray[n+5] + " ";
break;
}
}
/*
以下项目参数作者仅通过Canon相机Exif验证,在本脚本尚未使用。有兴趣的朋友可以自行尝试。
相机型号
if(stringTemp.indexOf("Model")!=-1)
{
ISOSpeedRatings = " ISO"+tempArray[n+1];
break;
}
制造公司
if(stringTemp.indexOf("Make")!=-1)
{
ISOSpeedRatings = " ISO"+tempArray[n+1];
break;
}
曝光模式
stringTemp=tempArray[n];
if(stringTemp.indexOf("ExposureProgram")!=-1)
{
ISOSpeedRatings = " ISO"+tempArray[n+1];
break;
}
焦距
if(stringTemp.indexOf("FocalLength")!=-1)
{
ISOSpeedRatings = " ISO"+tempArray[n+1];
break;
}
*/
//检查快门速度
dateArray1 = exposureTime.split("/");
exposureTime = "";
if(dateArray1 != ’’) //有的图片没有快门值
{
j = dateArray1[0];
i = dateArray1[1];
if(j/i >= 1)
exposureTime = parseInt(j/i) + parseInt(10*(j-parseInt(j/i)*i)/i)/10;
else
{
i = parseInt(10*parseFloat(i/j))/10;
j = 1;
exposureTime = j + "/" + i + "Sec ";
}
}
//计算光圈大小
dateArray1 = fNumber.split("/");
i = dateArray1[0];
j = dateArray1[1];
if(j>1)
fNumber = i/j;
else
fNumber = i;
if (fNumber != "") //有的图片没有光圈值
fNumber = "F/" + fNumber + " ";
//改变日期格式
dateArray1 = dateTimeOriginal.split("T");
if(dateArray1 != ’’) //有的图片没有日期值
{
phoDate = dateArray1[0];
phoTime = dateArray1[1];
//过滤时区信息。如果Exif里的时间无时区信息脚本运行提示这里出错,请把下面的4行代码用注释掉
dateArray2 = phoTime.split("+");
phoTime = dateArray2[0];
dateArray2 = phoTime.split("-");
phoTime = dateArray2[0];
//如果只要日期不要时间,请用下面的语句
//phoTime = ’’;
}
//定义黑色
var black = new SolidColor();
black.rgb.red = black.rgb.green = black.rgb.blue = 0;
//定义白色
var white = new SolidColor();
white.rgb.red = white.rgb.green = white.rgb.blue = 255;
//在相片的外边加入一条边框线
backgroundColor = fColor; //边框线颜色
AD.resizeCanvas(wFrame,hFrame, AnchorPosition.MIDDLECENTER);
//加入四边边框框底
backgroundColor = kColor;
AD.resizeCanvas(photoWidth + fWidth,photoHeight + fHeight, AnchorPosition.MIDDLECENTER); //可以修改参数获得不同的边框大小
//底部再加大点,便于写字,可以修改参数获得你需要的下边框大小
var addHeight = fHeight + parseInt(rFontSize) + parseInt(infoFontSize) + 6;
if (addHeight < 54) //限定最小加宽增加值,以防止选择最大号字体时出现高度不够
addHeight = 54;
AD.resizeCanvas(photoWidth + fWidth,photoHeight + addHeight,AnchorPosition.TOPCENTER);
//---------------- 标注主题文字开始 ----------------------
var nameLayer = AD.artLayers.add();
nameLayer.kind = LayerKind.TEXT;
var TI = nameLayer.textItem;
TI.justification = Justification.LEFT; //左对齐
TI.position = [fWidth/2,hFrame + fHeight/2 + parseInt(lFontSize)]; //设定主题文字位置
TI.contents = title; //文字的内容
TI.font = fontPSNames[builder.msgPnl.titleFont.et.selection.text]; //字体类型
TI.size = lFontSize; //字体大小,点数
TI.color = titleColor; //字体颜色,需预先定义
TI.fauxBold = true; //加粗
//---------------- 标注主题文字开始结束 ----------------------
//---------------- 标注说明文字开始 ----------------------
var msgLayer = AD.artLayers.add();
msgLayer.kind = LayerKind.TEXT;
var TI = msgLayer.textItem;
TI.justification = Justification.RIGHT; //右对齐
TI.position = [photoWidth + fWidth/2,hFrame + fHeight/2 + parseInt(rFontSize)]; //设定主题文字位置
TI.contents = body; //文字的内容
TI.font = fontPSNames[builder.msgPnl.msgFont.et.selection.text]; //字体类型
TI.size = rFontSize; //字体大小,点数
TI.color = msgColor; //字体颜色,需预先定义
TI.fauxBold = true; //加粗
//---------------- 标注说明文字始结束 ----------------------
//---------------- 标注拍摄信息开始 ----------------------
var infoLayer = AD.artLayers.add();
infoLayer.kind = LayerKind.TEXT;
var TI = infoLayer.textItem;
TI.justification = Justification.RIGHT; //右对齐
var addRightHeight = parseInt(infoFontSize); //拍摄信息高度的顶为值
if (body != "") //如果无有说明文字,则相应减少增加拍摄信息文字行的高度
{addRightHeight = parseInt(rFontSize) + parseInt(infoFontSize) + 6; }
TI.position = [photoWidth + fWidth/2,hFrame + fHeight/2 + addRightHeight]; //设定拍摄信息的位置,可以修改参数移动位
TI.contents = ""; //初始化值文字内容
TI.contents += lens + " "; //镜头型号
TI.contents += exposureTime; //快门速度
TI.contents += fNumber; //光圈
TI.contents += ISOSpeedRatings; //ISO值。尼康相机拍摄的相片可能没有该值
TI.contents += phoDate + " " + phoTime; //拍摄时间
TI.font = fontPSNames[builder.msgPnl.infoFont.et.selection.text]; //字体类型
TI.size = infoFontSize; //字体大小,点数
TI.color = infoColor; //字体颜色
TI.fauxBold = true; //加粗
//---------------- 标注拍摄信息结束 ----------------------
//最外边加入一条黑边线
backgroundColor = black;
AD.resizeCanvas(AD.width.value + 2,AD.height.value + 2, AnchorPosition.MIDDLECENTER);
AD.flatten(); //拼合图层
switch (frameSide) //将图片旋转回来
{
case 2:
app.activeDocument.rotateCanvas(-90.0);
break;
case 3:
app.activeDocument.rotateCanvas(90.0);
break;
}
}
//------------- Main script Begin ------------
var colorErr = "边框灰度值输入错误!" + "\n" + "系统将默认为黑色。";
var noLens = ’<不显示镜头信息>’;
var titleColor = new SolidColor(); //主题文字颜色
var msgColor = new SolidColor(); //说明文字颜色
var infoColor = new SolidColor(); //拍摄信息文字颜色
var titleFontColor; //主题颜色名称
var msgFontColor; //说明文字颜色名称
var infoFontColor; //拍摄信息颜色名称
var colors = new Array(); //颜色值数组
var colorNames = new Array(); //颜色名称数组
var frameSide = 1; //文字的位置代码。1为下面,2为右面,3为左面
//读取系统字体,定义字体名称及PostScript name of the font
var myFonts = new Array();
var fontPSNames = new Array();
for (i = 0;i < fonts.length;i ++)
{
if (! fontPSNames[fonts[i].family])
{
fontPSNames[fonts[i].family] = fonts[i].postScriptName;
myFonts.push(fonts[i].family);
}
}
var builder = createBuilderDialog(); //定义对话框内容
initializeBuilder(builder); //初始化状态值
if (runBuilder(builder) == 1)
{
var resSpec = createFrame(builder); //创建边框
}
//------------- Main script End -------------
//定义设置对话框 开始
function createBuilderDialog()
{
var myFontSizes = new Array(); //定义字体字号
myFontSizes[0] = 10;
myFontSizes[1] = 12;
myFontSizes[2] = 14;
myFontSizes[3] = 16;
myFontSizes[4] = 20;
myFontSizes[5] = 24;
myFontSizes[6] = 32;
var myLens = new Array(); //定义镜头。请自行修改为自己所拥有的镜头型号
myLens[0] = noLens; //请不要改动该行
myLens[1] = ’SIGMA AF 18-125mm F3.5-5.6 DC’;
myLens[2] = ’CANON EF 50mm F/1.8Ⅱ’;
//设置对话框界面文字内容
var optionTitle = ’相片边框信息设置[Build 20050820]’;
var msgPnlTitle = ’输入信息’;
var titleDescription = ’相片主题’;
var titleEditText = ’<请输入相片主题>’;
var fontSizeDescription = ’字号’;
var fontDescription = ’字体’;
var msgDescription = ’说明文字’;
var msgEditText = ’<请输入相片说明文字>’;
var lensDescription = ’拍摄信息’;
var frameWidthDescription = ’边框宽度’;
var frameWidthRadiobutton1 = ’宽边’;
var frameWidthRadiobutton2 = ’窄边’;
var frameColorDescription = ’ 边框灰度’;
var frameColorNote = ’(0为黑色,255为白色)’;
var labelSideDescription = ’标签位置’;
var labelSideText0 = ’自动’;
var labelSideText1 = ’下边’;
var labelSideText2 = ’右边’;
var labelSideText3 = ’左边’;
var labelSideNote = ’(自动:横幅时为下边,竖幅时为右边)’;
var okDescription = ’确定’;
var cancelDescription = ’取消’;
var colorDescription = ’颜色’;
//定义颜色名称及颜色值。用户可以改为自己喜欢的颜色
colorNames[0] = ’黑色’;
colors[colorNames[0]] = [0,0,0];
colorNames[1] = ’白色’;
colors[colorNames[1]] = [255,255,255];
colorNames[2] = ’褐色’;
colors[colorNames[2]] = [165,42,42];
colorNames[3] = ’金色’;
colors[colorNames[3]] = [255,215,0];
colorNames[4] = ’灰色’;
colors[colorNames[4]] = [128,128,128];
colorNames[5] = ’亮灰色’;
colors[colorNames[5]] = [211,211,211];
colorNames[6] = ’暗灰色’;
colors[colorNames[6]] = [169,169,169];
colorNames[7] = ’绿色’;
colors[colorNames[7]] = [0,128,0];
colorNames[8] = ’浅绿色’;
colors[colorNames[8]] = [0,255,255];
colorNames[9] = ’栗色’;
colors[colorNames[9]] = [128,0,0];
colorNames[10] = ’橙色’;
colors[colorNames[10]] = [255,165,0];
colorNames[11] = ’橄榄色’;
colors[colorNames[11]] = [128,128,0];
colorNames[12] = ’紫色’;
colors[colorNames[12]] = [128,0,128];
colorNames[13] = ’红色’;
colors[colorNames[13]] = [255,0,0];
colorNames[14] = ’银色’;
colors[colorNames[14]] = [192,192,192];
colorNames[15] = ’黄色’;
colors[colorNames[15]] = [255,255,0];
colorNames[16] = ’淡黄色’;
colors[colorNames[16]] = [245,222,179];
colorNames[17] = ’蓝色’;
colors[colorNames[17]] = [0,0,255];
colorNames[18] = ’暗蓝色’;
colors[colorNames[18]] = [0,0,139];
colorNames[19] = ’青色’;
colors[colorNames[19]] = [0,255,255];
colorNames[20] = ’茶色’;
colors[colorNames[20]] = [210,180,140];
var dlg = new Window(’dialog’, optionTitle);
//建立设置区面板。
dlg.msgPnl = dlg.add(’panel’, undefined, msgPnlTitle);
dlg.msgPnl.alignChildren = "left";
dlg.msgPnl.orientation = "column";
//有个不解的问题,移动调整代码行顺序,可获得不同的行间间隔。行间间隔是由dropdownlist产生的
dlg.msgPnl.titleFont = dlg.msgPnl.add(’group’); //主题字体
dlg.msgPnl.titleFontSize = dlg.msgPnl.add(’group’); //主体字号
dlg.msgPnl.title = dlg.msgPnl.add(’group’); //主题
dlg.msgPnl.msg = dlg.msgPnl.add(’group’); //说明文字
dlg.msgPnl.lens = dlg.msgPnl.add(’group’); //镜头型号
dlg.msgPnl.infoFont = dlg.msgPnl.add(’group’); //拍摄信息字体
dlg.msgPnl.infoFontSize = dlg.msgPnl.add(’group’); //拍摄信息字号
dlg.msgPnl.frameWidthh = dlg.msgPnl.add(’group’); //边框宽度
dlg.msgPnl.frameColor = dlg.msgPnl.add(’group’); //边框灰度
dlg.msgPnl.labelSide = dlg.msgPnl.add(’group’); //文字位置
dlg.msgPnl.msgFont = dlg.msgPnl.add(’group’); //说明文字字体
dlg.msgPnl.msgFontSize = dlg.msgPnl.add(’group’); //说明文字字号
dlg.msgPnl.titleColors = dlg.msgPnl.add(’group’); //主题文字颜色
dlg.msgPnl.msgColors = dlg.msgPnl.add(’group’); //说明文字颜色
dlg.msgPnl.infoColors = dlg.msgPnl.add(’group’); //拍摄信息颜色
with (dlg.msgPnl)
{
alignChildren = ’fill’;
title.st = title.add(’statictext’, undefined, titleDescription);
title.et = title.add(’edittext’, undefined, titleEditText,{multiline:false});
title.et.preferredSize = [200,20];
msg.st = msg.add(’statictext’, undefined, msgDescription);
msg.et = msg.add(’edittext’, undefined, msgEditText,{multiline:false});
msg.et.preferredSize = [200,20];
lens.st = lens.add(’statictext’, undefined, lensDescription);
lens.et = lens.add(’dropdownlist’, undefined, myLens);
lens.et.selection = 0; //指定镜头型号默认值索引数。从0开始计数。
lens.et.preferredSize = [200,20];
infoFontSize.st = lens.add(’statictext’, undefined, fontSizeDescription);
infoFontSize.et = lens.add(’dropdownlist’, undefined, myFontSizes);
infoFontSize.et.selection = 2; //指定拍摄信息字号默认值索引数。从0开始计数。
infoFontSize.et.preferredSize = [40,20];
infoFont.st = lens.add(’statictext’, undefined, fontDescription);
infoFont.et = lens.add(’dropdownlist’, undefined, myFonts);
infoFont.et.selection = 8; //指定拍摄信息字体默认值索引数。从0开始计数。
//infoFont.et.preferredSize = [140,20];
titleFontSize.st = title.add(’statictext’, undefined, fontSizeDescription);
titleFontSize.et = title.add(’dropdownlist’, undefined, myFontSizes);
titleFontSize.et.selection = 4; //指定主题字号默认值索引数。从0开始计数。
titleFontSize.et.preferredSize = [40,20];
msgFontSize.st = msg.add(’statictext’, undefined, fontSizeDescription);
msgFontSize.et = msg.add(’dropdownlist’, undefined, myFontSizes);
msgFontSize.et.selection = 2; //指定说明文字字号默认值索引数。从0开始计数。
msgFontSize.et.preferredSize = [40,20];
titleFont.st = title.add(’statictext’, undefined, fontDescription);
titleFont.et = title.add(’dropdownlist’, undefined, myFonts);
titleFont.et.selection = 5; //指定主题文字字体默认值索引数。从0开始计数。
//titleFont.et.preferredSize = [140,20];
msgFont.st = msg.add(’statictext’, undefined, fontDescription);
msgFont.et = msg.add(’dropdownlist’, undefined, myFonts);
msgFont.et.selection = 10; //指定说明文字字体默认值索引数。从0开始计数。
//msgFont.et.preferredSize = [140,20];
frameWidthh.st = frameWidthh.add(’statictext’, undefined, frameWidthDescription);
frameWidthh.frameWidth1 = frameWidthh.add(’radiobutton’, undefined, frameWidthRadiobutton1);
frameWidthh.frameWidth2 = frameWidthh.add(’radiobutton’, undefined, frameWidthRadiobutton2);
frameColor.st = frameWidthh.add(’statictext’, undefined, frameColorDescription);
frameColor.sl = frameWidthh.add(’slider’, undefined, 0, 0, 255); //中间的0为初始化值
frameColor.sl.preferredSize = [180, 20];
frameColor.et = frameWidthh.add(’edittext’);
frameColor.et.preferredSize = [40, 20];
frameColor.st = frameWidthh.add(’statictext’, undefined, frameColorNote);
labelSide.st = labelSide.add(’statictext’, undefined, labelSideDescription);
labelSide.labelSide0 = labelSide.add(’radiobutton’, undefined, labelSideText0);
labelSide.labelSide1 = labelSide.add(’radiobutton’, undefined, labelSideText1);
labelSide.labelSide2 = labelSide.add(’radiobutton’, undefined, labelSideText2);
labelSide.labelSide3 = labelSide.add(’radiobutton’, undefined, labelSideText3);
labelSide.st = labelSide.add(’statictext’, undefined, labelSideNote);
titleColors.st = title.add(’statictext’, undefined, colorDescription);
titleColors.et = title.add(’dropdownlist’, undefined, colorNames);
titleColors.et.selection = 3; //指定主题文字颜色默认值索引数。从0开始计数。
//titleColors.et.preferredSize = [60,20];
msgColors.st = msg.add(’statictext’, undefined, colorDescription);
msgColors.et = msg.add(’dropdownlist’, undefined, colorNames);
msgColors.et.selection = 1; //指定说明文字颜色默认值索引数。从0开始计数。
//msgColors.et.preferredSize = [60,20];
infoColors.st = lens.add(’statictext’, undefined, colorDescription);
infoColors.et = lens.add(’dropdownlist’, undefined, colorNames);
infoColors.et.selection = 1; //指定拍摄信息文字颜色默认值索引数。从0开始计数。
//infoColors.et.preferredSize = [60,20];
}
//建立按钮面板
dlg.btnPnl = dlg.add(’group’);
dlg.btnPnl.orientation = "row";
dlg.btnPnl.okBtn = dlg.btnPnl.add(’button’, undefined, okDescription, {name:’ok’});
dlg.btnPnl.cancelBtn = dlg.btnPnl.add(’button’, undefined, cancelDescription, {name:’cancel’});
dlg.center(); //设置对话框为屏幕中心位置
return dlg;
} // 定义设置对话框 结束
// Set up initial control states
// 初始化设置区信息
function initializeBuilder(builder)
{
with (builder)
{
btnPnl.okBtn.onClick = function () { this.parent.parent.close(1);};
btnPnl.cancelBtn.onClick = function () { this.parent.parent.close(2);};
with (msgPnl)
{
frameColor.et.text = frameColor.sl.value;
frameColor.et.onChange = function () { this.parent.parent.frameColor.sl.value = this.text; };
frameColor.sl.onChanging = function () { this.parent.parent.frameColor.et.text = parseInt(this.value); };
frameWidthh.frameWidth1.value = true; //边框默认值为宽边
//frameWidthh.frameWidth2.value = true; //边框默认值为窄边
labelSide.labelSide0.value = true; //标签位置默认值为自动
}
}
}
// This function invokes the dialog an returns its result
// 调用并返回对话框的结果
function runBuilder(builder)
{
return builder.show();
}
//分解Exif信息中的字符串。该获取Exif信息的方法引用于互联网上。
//本人觉得该方法不是太好,效率低,应该从XML格式文件中直接提取相关元素信息
function explodeArray(item) {
var i=0;
var Count=0;
var tempString=new String(item);
tempArray=new Array(1);
do{
i=tempString.indexOf(":");
if(i>0)
tempString=tempString.substr(i+1,tempString.length-i-1);
i=tempString.indexOf(">");
if(i>0) {
tempArray[Count]=tempString.substr(0,i);
tempString=tempString.substr(i+1,tempString.length-i-1);
Count ++;
}
i=tempString.indexOf("<");
if(i>0) {
tempArray[Count]=tempString.substr(0,i);
tempString=tempString.substr(i-1,tempString.length-i+1);
Count ++;
}
}while (tempString.indexOf("")>0);
tempArray[Count]=tempString;
return tempArray;
}
//生成相片边框动作
function createFrame(builder)
{
//AD = activeDocument; //在原相片上添加边框
var AD = activeDocument.duplicate(); //在相片的副本上添加边框
var photoWidth = AD.width.value; //图片宽度
var photoHeight = AD.height.value; //图片高度
if (photoWidth < photoHeight) //如果图片高度大于宽度则选择右侧标注文字
frameSide = 2;
if (builder.msgPnl.labelSide.labelSide1.value) //选择下侧标注文字
frameSide = 1;
if (builder.msgPnl.labelSide.labelSide2.value) //选择右侧标注文字
frameSide = 2;
if (builder.msgPnl.labelSide.labelSide3.value) //选择左侧标注文字
frameSide = 3;
switch (frameSide)
{
case 2:
app.activeDocument.rotateCanvas(90.0); //如果选择右侧标注文字则90度旋转
break;
case 3:
app.activeDocument.rotateCanvas(-90.0); //如果选择左侧标注文字则-90度旋转
break;
}
var title = builder.msgPnl.title.et.text; //获取相片主题
var body = builder.msgPnl.msg.et.text; //获取说明文字
var lens = builder.msgPnl.lens.et.selection.text; //获取镜头型号
var lFontSize = builder.msgPnl.titleFontSize.et.selection.text; //获取主题字号
var rFontSize = builder.msgPnl.msgFontSize.et.selection.text; //获取说明文字字号
var frameC = parseInt(builder.msgPnl.frameColor.sl.value); //获取边框灰度值
var infoFontSize = builder.msgPnl.infoFontSize.et.selection.text; //获取拍摄信息字号
var infoHeight = 0 //拍摄信息高度调整
titleFontColor = builder.msgPnl.titleColors.et.selection.text; //获取主题颜色名称
msgFontColor = builder.msgPnl.msgColors.et.selection.text; //获取说明文字颜色名称
infoFontColor = builder.msgPnl.infoColors.et.selection.text; //获取拍摄信息颜色名称
titleColor.rgb.red = colors[titleFontColor][0];
titleColor.rgb.green = colors[titleFontColor][1];
titleColor.rgb.blue = colors[titleFontColor][2];
msgColor.rgb.red = colors[msgFontColor][0];
msgColor.rgb.green = colors[msgFontColor][1];
msgColor.rgb.blue = colors[msgFontColor][2];
infoColor.rgb.red = colors[infoFontColor][0];
infoColor.rgb.green = colors[infoFontColor][1];
infoColor.rgb.blue = colors[infoFontColor][2];
if (body != ’’)
{
infoHeight = 20
}
if(frameC != frameC + 0)
{
Window.alert(colorErr);
frameC = 0;
}
if (lens != noLens)
{lens = builder.msgPnl.lens.et.selection.text;}
else
{lens = ’’;}
//宽边时参数
var fLong = 1/10; //边框宽度与相片宽度的倍数
//窄边时参数
if (builder.msgPnl.frameWidthh.frameWidth2.value)
{
fLong = 1/40;
}
var kColor = new SolidColor(); //框底色。通过滑杆赋值
var fColor = new SolidColor(); //内边线色。或者黑或者白
var rColor = new SolidColor(); //右边字体颜色。或者黑或者白
//初始化为黑色边框
kColor.rgb.red = kColor.rgb.green = kColor.rgb.blue = 0;
fColor.rgb.red = fColor.rgb.green = fColor.rgb.blue = 255;
rColor.rgb.red = rColor.rgb.green = rColor.rgb.blue = 255;
//如果frameC不等于0,则为灰色或白色边框
if (frameC != 0)
{
kColor.rgb.red = kColor.rgb.green = kColor.rgb.blue = frameC;
fColor.rgb.red = fColor.rgb.green = fColor.rgb.blue = 255 - frameC;
rColor.rgb.red = rColor.rgb.green = rColor.rgb.blue = 0;
}
var defaultRulerUnits = preferences.rulerUnits;
preferences.rulerUnits = Units.PIXELS;
var resRatio = AD.resolution/72;
if(resRatio != 1)
{
AD.resizeImage(AD.width.value,AD.height.value,72);
}
//定义参数
photoWidth = AD.width.value; //图片宽度
photoHeight = AD.height.value; //图片高度
var wFrame = AD.width.value + 2; //内框边线的宽度,单边实际宽度需除以2
var hFrame = AD.height.value + 2; //内框边线的高度,单边实际高度需除以2
var fWidth = parseInt(photoWidth*fLong); //边框底的宽度,单边实际宽度需除以2。
var fHeight = parseInt(photoWidth*fLong); //边框底的高度,单边实际高度需除以2。
//获取RAW相片保存的Exif信息
var exifData = AD.xmpMetadata.rawData.toString();
/*
//该工具提取相片的Exif完整信息为XML文件,并保存在c:\Exif.xml
var exifFileName = "c:\\Exif.xml";
var file = new File(exifFileName);
file.open(’w’);
file.writeln(exifData);
file.close();
alert("It has been written to " + exifFileName);
*/
//将EXIF信息分成单个的相关信息
explodeArray(exifData);
var exposureTime = ""; //快门
var fNumber = ""; //光圈
var ISOSpeedRatings = ""; //ISO设置
var dateTimeOriginal = ""; //相片拍摄时间
var phoDate = ""; //拍摄日期
var phoTime = ""; //拍摄时间
var i = 0;
var j = 0;
var k = 0;
var dateArray1 = "";
var dateArray2 = "";
//快门速度
for(n = 0; n < tempArray.length; n ++)
{
stringTemp = tempArray[n];
if(stringTemp.indexOf("ExposureTime") != -1)
{
exposureTime = tempArray[n+1];
break;
}
}
//光圈大小
for(n = 0; n < tempArray.length; n ++)
{
stringTemp = tempArray[n];
if(stringTemp.indexOf("FNumber") != -1)
{
fNumber = tempArray[n+1];
break;
}
}
//拍摄日期、时间
for(n = 0; n < tempArray.length; n ++)
{
stringTemp = tempArray[n];
if(stringTemp.indexOf("DateTimeOriginal") != -1)
{
dateTimeOriginal = tempArray[n+1];
break;
}
}
//ISO设置
for(n = 0; n < tempArray.length; n ++)
{
stringTemp = tempArray[n];
if(stringTemp.indexOf("ISOSpeedRatings") != -1)
{
ISOSpeedRatings = "ISO" + tempArray[n+5] + " ";
break;
}
}
/*
以下项目参数作者仅通过Canon相机Exif验证,在本脚本尚未使用。有兴趣的朋友可以自行尝试。
相机型号
if(stringTemp.indexOf("Model")!=-1)
{
ISOSpeedRatings = " ISO"+tempArray[n+1];
break;
}
制造公司
if(stringTemp.indexOf("Make")!=-1)
{
ISOSpeedRatings = " ISO"+tempArray[n+1];
break;
}
曝光模式
stringTemp=tempArray[n];
if(stringTemp.indexOf("ExposureProgram")!=-1)
{
ISOSpeedRatings = " ISO"+tempArray[n+1];
break;
}
焦距
if(stringTemp.indexOf("FocalLength")!=-1)
{
ISOSpeedRatings = " ISO"+tempArray[n+1];
break;
}
*/
//检查快门速度
dateArray1 = exposureTime.split("/");
exposureTime = "";
if(dateArray1 != ’’) //有的图片没有快门值
{
j = dateArray1[0];
i = dateArray1[1];
if(j/i >= 1)
exposureTime = parseInt(j/i) + parseInt(10*(j-parseInt(j/i)*i)/i)/10;
else
{
i = parseInt(10*parseFloat(i/j))/10;
j = 1;
exposureTime = j + "/" + i + "Sec ";
}
}
//计算光圈大小
dateArray1 = fNumber.split("/");
i = dateArray1[0];
j = dateArray1[1];
if(j>1)
fNumber = i/j;
else
fNumber = i;
if (fNumber != "") //有的图片没有光圈值
fNumber = "F/" + fNumber + " ";
//改变日期格式
dateArray1 = dateTimeOriginal.split("T");
if(dateArray1 != ’’) //有的图片没有日期值
{
phoDate = dateArray1[0];
phoTime = dateArray1[1];
//过滤时区信息。如果Exif里的时间无时区信息脚本运行提示这里出错,请把下面的4行代码用注释掉
dateArray2 = phoTime.split("+");
phoTime = dateArray2[0];
dateArray2 = phoTime.split("-");
phoTime = dateArray2[0];
//如果只要日期不要时间,请用下面的语句
//phoTime = ’’;
}
//定义黑色
var black = new SolidColor();
black.rgb.red = black.rgb.green = black.rgb.blue = 0;
//定义白色
var white = new SolidColor();
white.rgb.red = white.rgb.green = white.rgb.blue = 255;
//在相片的外边加入一条边框线
backgroundColor = fColor; //边框线颜色
AD.resizeCanvas(wFrame,hFrame, AnchorPosition.MIDDLECENTER);
//加入四边边框框底
backgroundColor = kColor;
AD.resizeCanvas(photoWidth + fWidth,photoHeight + fHeight, AnchorPosition.MIDDLECENTER); //可以修改参数获得不同的边框大小
//底部再加大点,便于写字,可以修改参数获得你需要的下边框大小
var addHeight = fHeight + parseInt(rFontSize) + parseInt(infoFontSize) + 6;
if (addHeight < 54) //限定最小加宽增加值,以防止选择最大号字体时出现高度不够
addHeight = 54;
AD.resizeCanvas(photoWidth + fWidth,photoHeight + addHeight,AnchorPosition.TOPCENTER);
//---------------- 标注主题文字开始 ----------------------
var nameLayer = AD.artLayers.add();
nameLayer.kind = LayerKind.TEXT;
var TI = nameLayer.textItem;
TI.justification = Justification.LEFT; //左对齐
TI.position = [fWidth/2,hFrame + fHeight/2 + parseInt(lFontSize)]; //设定主题文字位置
TI.contents = title; //文字的内容
TI.font = fontPSNames[builder.msgPnl.titleFont.et.selection.text]; //字体类型
TI.size = lFontSize; //字体大小,点数
TI.color = titleColor; //字体颜色,需预先定义
TI.fauxBold = true; //加粗
//---------------- 标注主题文字开始结束 ----------------------
//---------------- 标注说明文字开始 ----------------------
var msgLayer = AD.artLayers.add();
msgLayer.kind = LayerKind.TEXT;
var TI = msgLayer.textItem;
TI.justification = Justification.RIGHT; //右对齐
TI.position = [photoWidth + fWidth/2,hFrame + fHeight/2 + parseInt(rFontSize)]; //设定主题文字位置
TI.contents = body; //文字的内容
TI.font = fontPSNames[builder.msgPnl.msgFont.et.selection.text]; //字体类型
TI.size = rFontSize; //字体大小,点数
TI.color = msgColor; //字体颜色,需预先定义
TI.fauxBold = true; //加粗
//---------------- 标注说明文字始结束 ----------------------
//---------------- 标注拍摄信息开始 ----------------------
var infoLayer = AD.artLayers.add();
infoLayer.kind = LayerKind.TEXT;
var TI = infoLayer.textItem;
TI.justification = Justification.RIGHT; //右对齐
var addRightHeight = parseInt(infoFontSize); //拍摄信息高度的顶为值
if (body != "") //如果无有说明文字,则相应减少增加拍摄信息文字行的高度
{addRightHeight = parseInt(rFontSize) + parseInt(infoFontSize) + 6; }
TI.position = [photoWidth + fWidth/2,hFrame + fHeight/2 + addRightHeight]; //设定拍摄信息的位置,可以修改参数移动位
TI.contents = ""; //初始化值文字内容
TI.contents += lens + " "; //镜头型号
TI.contents += exposureTime; //快门速度
TI.contents += fNumber; //光圈
TI.contents += ISOSpeedRatings; //ISO值。尼康相机拍摄的相片可能没有该值
TI.contents += phoDate + " " + phoTime; //拍摄时间
TI.font = fontPSNames[builder.msgPnl.infoFont.et.selection.text]; //字体类型
TI.size = infoFontSize; //字体大小,点数
TI.color = infoColor; //字体颜色
TI.fauxBold = true; //加粗
//---------------- 标注拍摄信息结束 ----------------------
//最外边加入一条黑边线
backgroundColor = black;
AD.resizeCanvas(AD.width.value + 2,AD.height.value + 2, AnchorPosition.MIDDLECENTER);
AD.flatten(); //拼合图层
switch (frameSide) //将图片旋转回来
{
case 2:
app.activeDocument.rotateCanvas(-90.0);
break;
case 3:
app.activeDocument.rotateCanvas(90.0);
break;
}
}
VFP应用程序设计
个人所得税应用程序设计 (JAVA编写)
《IBM-汇编语言程序设计》答案
可视化程序设计的社会应用及其发展前景
可视化程序设计专业的社会应用情况
web应用程序设计社会应用情况和今后的发展前景
信尾的ps是什么意思?
EXIF 数据
求MCP考试,SQL Server 2000数据库程序设计,基于C#的Windows应用程序设计考试题库
求助:基于j2me移动通信程序设计研究与应用(综述)
应该怎么样学习好电脑的程序设计。和软件应用
C#windows应用程序设计的一个小问题?
c#windows应用程序设计父子窗体的设计问题?
Visual C#.NET Web应用程序设计入门与提高
《Visual C#.NET Web应用程序设计入门与提高 》
关于FLASH制作中的脚本应用问题
程序设计
程序设计
程序设计
程序设计
程序设计
程序设计
程序设计
求应用电子技术毕业自荐信范文