主题:发个帖子,定制各种Photoshop边框
正序浏览
主题图片汇总
主题内检索
泡菜
泡网分: 7.467
主题: 48
帖子: 7232
注册: 2007年7月
年内主力装备
★ NIKON Z 8
最近有空,发个帖子,为大家编写photoshop的脚本,定制各种边框。

可以添加边框,可以添加logo,可以打印EXIF数据,可以添加照片标题文字。

1、首先把logo图片放入一个文件夹,比如“D:\logo”,比如这里示例的脚本logo图片叫做“色影无忌.PNG”。

登录后可直接显示原图

2、把下面的代码粘贴到一个文本文件,保存,修改后缀为“.jsx”,比如“定制边框.jsx”,也放入logo文件夹。

3、使用时,Photoshop菜单“文件”-“脚本”-“浏览”,找到logo文件夹,选中“定制边框.jsx”,“载入”(确定)。用photoshop的“动作”来运行这个脚本更方便。

//---------------定义各种颜色------------------------------------------------------------------
var black=new SolidColor();
black.rgb.red=0;black.rgb.green=0;black.rgb.blue=0; //定义黑色
var white=new SolidColor();
white.rgb.red=255;white.rgb.green=255;white.rgb.blue=255;//定义白色
var lightgrey=new SolidColor();
lightgrey.rgb.red=204;lightgrey.rgb.green=204;lightgrey.rgb.blue=204; //定义亮灰,你也可以定义其他颜色
var darkgrey=new SolidColor();
darkgrey.rgb.red=20;darkgrey.rgb.green=20;darkgrey.rgb.blue=20; //定义暗灰,你也可以定义其他颜色
var green=new SolidColor();
green.rgb.red=118;green.rgb.green=151;green.rgb.blue=56;//定义绿色,你也可以定义其他颜色
var red=new SolidColor();
red.rgb.red=200;red.rgb.green=100;red.rgb.blue=40;//定义红色,你也可以定义其他颜色
var blue=new SolidColor();
blue.rgb.red=98;blue.rgb.green=95;blue.rgb.blue=150;
//----------------------------------------------------------------------------------------------

//----------------缩图和锐化-------------------------------------------------------------------
var resizeValue=1350;//边长像素数,可以根据需要修改
var SHORTSIDE=true;//true以短边为准,如果以长边为准SHORTSIDE=false
var DORESIZE=false;//是否缩图,true缩图,false不缩图
var DOSMARTSHARPEN=false;//是否锐化,true锐化,false不锐化
//----------------------------------------------------------------------------------------------

//----------------加框--------------------------------------------------------------------------
var INNER=false;//true画布不扩大,信息打印在照片上,false扩大画布,信息打印在边框上
var B1L=0;//第一层左边框宽度,按需要修改
var B1R=0;//第一层右边框宽度,按需要修改
var B1T=0;//第一层上边框宽度,按需要修改
var B1B=2;//第一层下边框宽度,按需要修改
var B1COLOR=black;//第一层边框颜色
var B2L=0;//第二层左边框宽度,按需要修改
var B2R=0;//第二层右边框宽度,按需要修改
var B2T=0;//第二层上边框宽度,按需要修改
var B2B=120;//第二层下边框宽度,按需要修改
//var B2COLOR=lightgrey;//第二层边框颜色
var B2COLOR=blue;
var BORDERTRANSPARENT=false;//第二层边框是否透明,true透明,false普通
var BORDERPARTTERN1=false;//使用图案填充第一层边框
var BORDERPARTTERN2=false;//使用图案填充第二层边框
var DOBORDER=true;//是否添加边框,true加框,false不加框
var BORDERSHADOW=false;//是否添加边框阴影,true有阴影,false无阴影
//----------------------------------------------------------------------------------------------

//---------------提取、打印Exif信息------------------------------------------------------------
var exifFontsType="Arial-BoldItalicMT";
var exifFontsItalic=true;
var exifFontsBold=false;
var exifFontsSize=8;
var exifFontsColor=white;
var exifFontsPosition="下右";//"上左"、"上中”、"上右"、"中左"、"中”、"中右"、"下左"、"下中"、"下右"
var exifPositionXX=0;//微调打印位置
var exifPositionYY=0;//微调打印位置
var DOEXIFMESSAGE=true;//是否打印Exif信息,true打印,false不打印
var EXIFSHADOW=true;//是否添加边框阴影,true有阴影,false无阴影
var EXIFVERTICAL=false;//打印方向,true垂直,false水平
//----------------------------------------------------------------------------------------------

//---------------打印照片标题------------------------------------------------------------------
//照片标题为照片文件名最前面的字符,比如,“我的美图.xxx.TIF”,用“.”隔开,打印标题为“我的美图”
var titleFontsType="STCaiyun";
//var titleFontsType="STHupo";//var titleFontsType="MicrosoftYaHei-Bold";//var titleFontsType="KaiTi";//var titleFontsType="SimHei";
var titleFontsItalic=false;
var titleFontsBold=false;
var titleFontsTypeBug="STKaiti";
var titleFontsBoldBug=true;
var titleFontsSize=30;
var titleFontsColor=white;
var titleFontsPosition="下左";//"上左"、"上中”、"上右"、"中左"、"中”、"中右"、"下左"、"下中"、"下右"
var titlePositionXX=-0;//微调打印位置
var titlePositionYY=0;//微调打印位置
var DOPHOTOTITLE=false;//是否打印照片标题,true打印,false不打印
var TITLESHADOW=true;//是否添加边框阴影,true有阴影,false无阴影
var TITLEVERTICAL=false;//打印方向,true垂直,false水平
//----------------------------------------------------------------------------------------------

//--------------打印logo------------------------------------------------------------------------
var logoFile="D:\\logo\\色影无忌.PNG";//logo图片,反斜线要用2个“\\”
var logoPosition="下左";//"上左"、"上中”、"上右"、"中左"、"中”、"中右"、"下左"、"下中"、"下右"
var logoPositionXX=0;//微调打印位置
var logoPositionYY=0;//微调打印位置
var logoSize=200;//logo图片宽度,改变这个像素数,可以调整打印logo的大小
var DOLOGO=true;//是否打印logo,true打印,false不打印
var LOGOSHADOW=true;//是否添加边框阴影,true有阴影,false无阴影
var LOGOVERTICAL=false;//打印方向,true垂直,false水平
//----------------------------------------------------------------------------------------------

//--------------保存JPEG照片-------------------------------------------------------------------
var JpegFilePath="D:\\Photo JPEG";//存储JPEG的路径,反斜线要用2个“\\”
var JPEGQUALITY=10;//JPEG文件质量
var DOJPEGSAVE=false;//是否保存JPEG文件,true保存,false不保存
//----------------------------------------------------------------------------------------------

//-------------关闭当前图片文档----------------------------------------------------------------
var DOPHOTOCLOSE=false;//是否关闭当前照片文档,true关闭,false不关闭
//----------------------------------------------------------------------------------------------

//----下面这段是针对没有Exif信息的手动镜头的情况,需要自己添加信息--------------------------
var MANUALLENS=false;//是否添加无Exif的手动镜头信息,true添加,false不添加
var manualLens="Zuiko OM F1.4 50mm";//镜头型号,请根据自己的情况修改
var manualFNumber="5.6";//使用的光圈,请根据自己的情况修改
var manualFocalLength="50";//使用的镜头焦距,请根据自己的情况修改
//----------------------------------------------------------------------------------------------

//----------------------------------------------------------------------------------------------
//  下面的代码部分不用理会、不必修改
//----------------------------------------------------------------------------------------------
//displayDialogs=DialogModes.NO;
B1L=Math.abs(B1L);B1R=Math.abs(B1R);B1T=Math.abs(B1T);B1B=Math.abs(B1B);
B2L=Math.abs(B2L);B2R=Math.abs(B2R);B2T=Math.abs(B2T);B2B=Math.abs(B2B);

var MyPhoto=activeDocument;
var MyPhotoResolution=MyPhoto.resolution;
var MyPhotoBits=MyPhoto.bitsPerChannel;
var MyPhotoColorSpace=MyPhoto.colorProfileName;
MyPhoto.bitsPerChannel=BitsPerChannelType.SIXTEEN;
MyPhoto.convertProfile("ProPhoto RGB",Intent.RELATIVECOLORIMETRIC,false,false);
MyPhoto.flatten();
MyPhoto.backgroundLayer.name="图层 0";
if(BORDERTRANSPARENT==true&&INNER==false){
    if(SHORTSIDE==true){resizeValue=resizeValue+B1T+B1B+B2T+B2B;}
    else{resizeValue=resizeValue+B1L+B1R+B2L+B2R;}
    INNER=true;
    }
var resizeRatio=rsResizeImage(MyPhoto,resizeValue,SHORTSIDE);
if(DOBORDER==true){rsBorderAdding(MyPhoto,Array(B1L,B1R,B1T,B1B),B1COLOR,Array(B2L,B2R,B2T,B2B),B2COLOR,INNER);}
var ExifDateTimeOriginal=rsExifMessageOut(MyPhoto,exifFontsPosition,exifPositionXX,exifPositionYY);
if(DOPHOTOTITLE==true){rsPhotoTitleOut(MyPhoto,titleFontsPosition,titlePositionXX,titlePositionYY);}
if(DOLOGO==true){rsOutLogoPicture(MyPhoto,logoFile,logoPosition,logoSize,logoPositionXX,logoPositionYY);}
MyPhoto.flatten();
MyPhoto.resizeImage(MyPhoto.width.value,MyPhoto.height.value,MyPhotoResolution,ResampleMethod.BICUBICSHARPER);
MyPhoto.convertProfile(MyPhotoColorSpace,Intent.RELATIVECOLORIMETRIC,false,false);
MyPhoto.bitsPerChannel=MyPhotoBits;
if(DOJPEGSAVE==true){rsJpegPhotoSave(MyPhoto,JpegFilePath,JPEGQUALITY);}
if(DOPHOTOCLOSE==true){MyPhoto.close(SaveOptions.DONOTSAVECHANGES)};

function rsResizeImage(photo,imagelength,shortside)
{
    var resizeRatio;
    var resizeWidth=photo.width.value;var resizeHeight=photo.height.value;
    var photoRatio=resizeWidth/resizeHeight;
    if(DORESIZE==true){
        if(photoRatio>=1){
            if(shortside==true){
                imagelength=(resizeHeight<imagelength)?resizeHeight:imagelength;
                resizeRatio=imagelength/1350;
                resizeWidth=parseInt(imagelength*photoRatio+0.5);resizeHeight=imagelength;
                }
            else{
                imagelength=(resizeWidth<imagelength)?resizeWidth:imagelength;
                resizeRatio=imagelength/2025;
                resizeWidth=imagelength;resizeHeight=parseInt(imagelength/photoRatio+0.5);
                }
            }
        else{
            if(shortside==true){
                imagelength=(resizeWidth<imagelength)?resizeWidth:imagelength;
                resizeRatio=imagelength/1350;
                resizeHeight=parseInt(imagelength/photoRatio+0.5);resizeWidth=imagelength;
                }
            else{
                imagelength=(resizeHeight<imagelength)?resizeHeight:imagelength;
                resizeRatio=imagelength/2025;
                resizeHeight=imagelength;resizeWidth=parseInt(imagelength*photoRatio+0.5);
                }
            }
        }
    else{
        if(photoRatio>=1){
            if(shortside==true){resizeRatio=resizeHeight/1350;}
            else{resizeRatio=resizeWidth/2025;}
            }
        else{
            if(shortside==true){resizeRatio=resizeWidth/1350;}
            else{resizeRatio=resizeHeight/2050;}
            }
        }
    photo.resizeImage(resizeWidth,resizeHeight,180,ResampleMethod.BICUBICSHARPER);

    if(DOSMARTSHARPEN==true){
        photo.activeLayer=photo.artLayers.getByName("图层 0");
        photo.changeMode(ChangeMode.LAB);
        var achannel=photo.channels.getByName("a");achannel.visible=false;
        var bchannel=photo.channels.getByName("b");bchannel.visible=false;
        var amount=80;var radius=0.8;var threshold=2;
        photo.activeLayer.applyUnSharpMask(amount,radius,threshold);
        photo.changeMode(ChangeMode.RGB);
        MyPhoto.bitsPerChannel=BitsPerChannelType.SIXTEEN;
        MyPhoto.convertProfile("ProPhoto RGB",Intent.RELATIVECOLORIMETRIC,false,false);
        }
    return resizeRatio;
}

function rsBorderAdding(photo,border1,color1,border2,color2,inner)
{
    var labcolor1=new SolidColor();labcolor1.lab=color1.lab;
    var labcolor2=new SolidColor();labcolor2.lab=color2.lab;
    var borderLayer0=photo.artLayers.getByName("图层 0");
    photo.activeLayer=borderLayer0;
    if(photo.artLayers.length>1){photo.mergeVisibleLayers();}
    for(var i=0;i<border1.length;i++){
        if(border1>0){border1[i]=parseInt(border1[i]*resizeRatio);border1[i]=(border1[i]>0)?border1[i]:1;}
if(border2[i]>0){border2[i]=parseInt(border2[i]*resizeRatio);border2[i]=(border2[i]>0)?border2[i]:1;}
}
if(inner==false){
photo.resizeCanvas(photo.width.value+border1[0]+border2[0],photo.height.value+border1[2]+border2[2],AnchorPosition.BOTTOMRIGHT);
photo.resizeCanvas(photo.width.value+border1[1]+border2[1],photo.height.value+border1[3]+border2[3],AnchorPosition.TOPLEFT);
}
var borderLayer1=photo.artLayers.add();
var pointLT=Array(border2[0],border2[2]);
var pointRT=Array(photo.width.value-border2[1],border2[2]);
var pointRB=Array(photo.width.value-border2[1],photo.height.value-border2[3]);
var pointLB=Array(border2[0],photo.height.value-border2[3]);
var selRegion1=Array(pointRT,pointRB,pointLB,pointLT);
photo.selection.select(selRegion1,SelectionType.REPLACE,0,true);
if(BORDERPARTTERN1==true){partternfilling("JavaScript","fillparttern1");}
else{photo.selection.fill(labcolor1,ColorBlendMode.NORMAL,100,false);}
photo.selection.deselect();
pointLT=Array(border2[0]+border1[0],border2[2]+border1[2]);
pointRT=Array(photo.width.value-border2[1]-border1[1],border2[2]+border1[2]);
pointRB=Array(photo.width.value-border2[1]-border1[1],photo.height.value-border2[3]-border1[3]);
pointLB=Array(border2[0]+border1[0],photo.height.value-border2[3]-border1[3]);
var selRegion2=Array(pointRT,pointRB,pointLB,pointLT);
photo.selection.select(selRegion2,SelectionType.REPLACE,0,true);
photo.selection.clear();
photo.selection.deselect();
if(BORDERSHADOW==true){
var shadowwidth=(Math.max(border1[0],border1[1],border1[2],border1[3])/4+1)*resizeRatio*1.15;
projectionstyle(shadowwidth);
}
if(BORDERTRANSPARENT==false){
if(border2[0]+border2[1]+border2[2]+border2[3]>0){
photo.activeLayer=borderLayer0;
photo.selection.select(selRegion1,SelectionType.REPLACE,0,true);
photo.selection.invert();
if(BORDERPARTTERN2==true){partternfilling("JavaScript","fillparttern2");}
else{photo.selection.fill(labcolor2,ColorBlendMode.NORMAL,100,false);}
photo.selection.deselect();
}
}
photo.activeLayer=borderLayer0;
photo.mergeVisibleLayers();
}

function rsPhotoTitleOut(photo,position,xx,yy)
{
var photoTitle=photo.name.split("@");photoTitle=photoTitle[0];
var widthtmp=photo.width.value;var heighttmp=photo.height.value;
var yytemp;var xxtemp;var justification;
var direction;var yyTop;var yyCenter;var yyBottom;var xxLeft;var xxCenter;var xxRight;var justification;
var fonttype=titleFontsType;
var fontitalic=titleFontsItalic;var fontbold=titleFontsBold;var fontsize=titleFontsSize;var fontcolor=titleFontsColor;
var titlepatch=false;
if(TITLEVERTICAL==false){
direction=Direction.HORIZONTAL;
yyTop=180*(fontsize*resizeRatio/100)+30*resizeRatio;
yyCenter=heighttmp/2+180*(fontsize*resizeRatio/100)/2;
yyBottom=heighttmp-40*resizeRatio;
xxLeft=20*resizeRatio;xxCenter=widthtmp/2;xxRight=widthtmp-20*resizeRatio;
switch(position){
case "上左":yytemp=yyTop;xxtemp=xxLeft;justification=Justification.LEFT;break;
case "上中":yytemp=yyTop;xxtemp=xxCenter;justification=Justification.CENTER;break;
case "上右":yytemp=yyTop;xxtemp=xxRight;justification=Justification.RIGHT;break;
case "中左":yytemp=yyCenter;xxtemp=xxLeft;justification=Justification.LEFT;break;
case "中":yytemp=yyCenter;xxtemp=xxCenter;justification=Justification.CENTER;break;
case "中右":yytemp=yyCenter;xxtemp=xxRight;justification=Justification.RIGHT;break;
case "下左":yytemp=yyBottom;xxtemp=xxLeft;justification=Justification.LEFT;break;
case "下中":yytemp=yyBottom;xxtemp=xxCenter;justification=Justification.CENTER;break;
case "下右":yytemp=yyBottom;xxtemp=xxRight;justification=Justification.RIGHT;break;
default:yytemp=yyBottom;xxtemp=xxLeft;justification=Justification.LEFT;break;
}
}
else{
direction=Direction.VERTICAL;
yyTop=20*resizeRatio;yyCenter=heighttmp/2;yyBottom=heighttmp-20*resizeRatio;
xxLeft=180*(fontsize*resizeRatio/100)/2+20*resizeRatio;
xxCenter=widthtmp/2;
xxRight=widthtmp-180*(fontsize*resizeRatio/100)/2-20*resizeRatio;
switch(position){
case "上左":yytemp=yyTop;xxtemp=xxLeft;justification=Justification.LEFT;break;
case "上中":yytemp=yyTop;xxtemp=xxCenter;justification=Justification.LEFT;break;
case "上右":yytemp=yyTop;xxtemp=xxRight;justification=Justification.LEFT;break;
case "中左":yytemp=yyCenter;xxtemp=xxLeft;justification=Justification.CENTER;break;
case "中":yytemp=yyCenter;xxtemp=xxCenter;justification=Justification.CENTER;break;
case "中右":yytemp=yyCenter;xxtemp=xxRight;justification=Justification.CENTER;break;
case "下左":yytemp=yyBottom;xxtemp=xxLeft;justification=Justification.RIGHT;break;
case "下中":yytemp=yyBottom;xxtemp=xxCenter;justification=Justification.RIGHT;break;
case "下右":yytemp=yyBottom;xxtemp=xxRight;justification=Justification.RIGHT;break;
default:yytemp=yyBottom;xxtemp=xxLeft;justification=Justification.RIGHT;break;
}
}
xxtemp=xxtemp+xx*resizeRatio;yytemp=yytemp+yy*resizeRatio;
titlepatch=titlepatch||photoTitle=="暗灰鹃鵙";
titlepatch=titlepatch||photoTitle=="小鸊鷉";
titlepatch=titlepatch||photoTitle=="斑头鸺鹠";
titlepatch=titlepatch||photoTitle=="环颈鸻";
titlepatch=titlepatch||photoTitle=="白鹡鸰";
titlepatch=titlepatch||photoTitle=="黄喉鹀";
titlepatch=titlepatch||photoTitle=="白眉姬鹟";
if(titlepatch){fonttype=titleFontsTypeBug;fontbold=titleFontsBoldBug;}
TextOut(photo,photoTitle,fonttype,fontitalic,fontbold,fontsize*resizeRatio,fontcolor,xxtemp,yytemp,justification,direction);
if(TITLESHADOW==true){
var shadowwidth=fontsize*resizeRatio/100*180*0.2;
projectionstyle(shadowwidth);
}
photo.activeLayer=photo.artLayers.getByName("图层 0");
photo.mergeVisibleLayers();
}

function rsExifMessageOut(photo,position,xx,yy)
{
var i;var j;var n;var temp;
var paraArray=xmpMetaDataArray(photo.xmpMetadata.rawData.toString());

var xmpRawFileName="";
for(n=0;n<paraArray.length;n++){
if(paraArray[n]=="RawFileName"){xmpRawFileName=paraArray[n+1];break;}
}
var exifMake="";
for(n=0;n<paraArray.length;n++){
if(paraArray[n]=="Make"){exifMake=paraArray[n+1];break;}
}
var exifModel="";
for(n=0;n<paraArray.length;n++){
if(paraArray[n]=="Model"){exifModel=paraArray[n+1];break;}
}
var exifLens="";
for(n=0;n<paraArray.length;n++){
if(paraArray[n]=="Lens"||paraArray[n]=="LensModel"){
if(paraArray[n+1]=="200mm f/2.8G"){exifLens="Canon EF200mm f/2.8L II USM";}
else if(paraArray[n+1]=="85mm f/1.2G"){exifLens="Canon EF85mm f/1.2L II USM";}
else if(paraArray[n+1]=="24-70mm f/2.8G"){exifLens="Canon EF 24-70mm f/2.8L II USM";}
else if(paraArray[n+1]=="24-105mm f/4G"){exifLens="Canon EF24-105mm f/4L IS USM";}
else if(paraArray[n+1]=="100mm f/2.8G"){exifLens="Canon EF100mm f/2.8L IS USM";}
else if(paraArray[n+1]=="17-40mm f/4G"){exifLens="Canon EF17-40mm f/4L USM";}
else if(paraArray[n+1]=="15mm f/2.8G"){exifLens="Canon EF15mm f/2.8 Fisheye";}
else if(paraArray[n+1]=="100-400mm f/4.5-5.6G"){exifLens="Canon EF100-400mm f/4.5-5.6L IS USM";}
else if(paraArray[n+1]=="24mm f/1.4G"){exifLens="Sigma 24mm f/1.4 DG HSM";}
else{exifLens=paraArray[n+1];}
break;
}
}
var exifFNumber="";
for(n=0;n<paraArray.length;n++){
if(paraArray[n]=="FNumber"&¶Array[n+1].indexOf("/")>=0){exifFNumber=paraArray[n+1];break;}
}
if(exifFNumber!=""){temp=exifFNumber.split("/");exifFNumber=temp[0]/temp[1];}
else{exifFNumber=0;}
var exifExposureTime="";
for(n=0;n<paraArray.length;n++){
if(paraArray[n]=="ExposureTime"&¶Array[n+1].indexOf("/")>=0){exifExposureTime=paraArray[n+1];break;}
}
temp=exifExposureTime.split("/");j=temp[0];i=temp[1];
if(j/i>=1){exifExposureTime=parseInt(j/i)+"."+(j-parseInt(j/i)*i);}
else{i=parseInt(i/j);j=1;exifExposureTime=j+"/"+i;}
var exifISOSpeedRatings="";
for(n=0;n<paraArray.length;n++){
if(paraArray[n]=="ISOSpeedRatings"){exifISOSpeedRatings="ISO"+paraArray[n+5];break;}
}
var exifExposureBiasValue="";
for(n=0;n<paraArray.length;n++){
if(paraArray[n]=="ExposureBiasValue" && paraArray[n+1].indexOf("/")>=0){exifExposureBiasValue=paraArray[n+1];break;}
}
temp=exifExposureBiasValue.split("/");i=temp[0];j=temp[1];exifExposureBiasValue=i/j;
if(exifExposureBiasValue>=0){exifExposureBiasValue="+"+parseInt(exifExposureBiasValue*10+0.5)/10;}
else{exifExposureBiasValue="-"+parseInt(-exifExposureBiasValue*10+0.5)/10;}
if(exifExposureBiasValue.indexOf(".")<0){exifExposureBiasValue=exifExposureBiasValue+".0";}
var exifFocalLength="";
for(n=0;n<paraArray.length;n++){
if(paraArray[n]=="FocalLength"&¶Array[n+1].indexOf("/")>=0){exifFocalLength=paraArray[n+1];break;}
}
if(exifFocalLength!=""){temp=exifFocalLength.split("/");i=temp[0];j=temp[1];exifFocalLength=parseInt(i/j);}
var exifFocalLengthIn35mmFilm="";
for(n=0;n<paraArray.length;n++){
if(paraArray[n]=="FocalLengthIn35mmFilm"){exifFocalLengthIn35mmFilm=paraArray[n+1];break;}
}
var exifDateTimeOriginal="";
for(n=0;n<paraArray.length;n++){
if(paraArray[n]=="DateTimeOriginal"){exifDateTimeOriginal=paraArray[n+1];break;}
}
var exifPhotoDate="";exifPhotoTime="";
if(exifDateTimeOriginal!=""){
var delZero=["1","2","3","4","5","6","7","8","9","10", "11","12","13","14","15","16","17","18","19","20", "21","22","23","24","25","26","27","28","29", "30","31"];
temp=exifDateTimeOriginal.split("T");exifPhotoDate=temp[0];exifPhotoTime=temp[1];
temp=exifPhotoDate.split("-"); exifPhotoDate=temp[0]+"/"+delZero[temp[1]-1]+"/"+delZero[temp[2]-1];
temp=exifPhotoTime.split("+");exifPhotoTime=temp[0];temp=exifPhotoTime.split(":");
if(temp.length==2){exifPhotoTime=temp[0]+":"+temp[1]+":00";}
else{exifPhotoTime=temp[0]+":"+temp[1]+":"+temp[2];}
}
else{exifPhotoDate="0000/0/0";exifPhotoTime="00:00:00"}
if(MANUALLENS==true){
if(manualLens!=""){exifLens=manualLens}
if(manualFNumber!=""){exifFNumber=manualFNumber;}
if(manualFocalLength!=""){exifFocalLength=manualFocalLength;}
}

if(DOEXIFMESSAGE==true){
var fontsize=exifFontsSize;
var widthtmp=photo.width.value;var heighttmp=photo.height.value;
var yytemp,xxtemp;
var direction;var yyTop;var yyCenter;var yyBottom;var xxLeft;var xxCenter;var xxRight;var justification;

n=0;
var contents="";
if(exifLens!=""){contents=exifModel+"\r"+exifLens;n=n+1;}
else{contents=exifModel;}
contents=contents+"\r"+" F"+exifFNumber+" "+exifExposureTime;n=n+1;
contents=contents+" "+exifISOSpeedRatings+" "+exifExposureBiasValue+"EV";n=n+1;
if(exifFocalLength!=""){contents=contents+" "+exifFocalLength+" mm";}
if(exifFocalLengthIn35mmFilm!=""){contents=contents+" ("+exifFocalLengthIn35mmFilm+" mm)";}
contents=contents+"\r"+exifPhotoDate+" "+exifPhotoTime;n=n+1;

if(EXIFVERTICAL==false){
direction=Direction.HORIZONTAL;
yyTop=180*(fontsize*resizeRatio/100)+20*resizeRatio;
yyCenter=heighttmp/2-180*(fontsize*resizeRatio/100)*((1+2/3)*(n/2-1)+2/3/2);
yyBottom=heighttmp-180*(fontsize*resizeRatio/100)*(1+2/3)*(n-1)-20*resizeRatio;
xxLeft=20*resizeRatio;xxCenter=widthtmp/2;xxRight=widthtmp-20*resizeRatio;
switch(position){
case "上左":yytemp=yyTop;xxtemp=xxLeft;justification=Justification.LEFT;break;
case "上中":yytemp=yyTop;xxtemp=xxCenter;justification=Justification.CENTER;break;
case "上右":yytemp=yyTop;xxtemp=xxRight;justification=Justification.RIGHT;break;
case "中左":yytemp=yyCenter;xxtemp=xxLeft;justification=Justification.LEFT;break;
case "中":yytemp=yyCenter;xxtemp=xxCenter;justification=Justification.CENTER;break;
case "中右":yytemp=yyCenter;xxtemp=xxRight;justification=Justification.RIGHT;break;
case "下左":yytemp=yyBottom;xxtemp=xxLeft;justification=Justification.LEFT;break;
case "下中":yytemp=yyBottom;xxtemp=xxCenter;justification=Justification.CENTER;break;
case "下右":yytemp=yyBottom;xxtemp=xxRight;justification=Justification.RIGHT;break;
default:yytemp=yyBottom;xxtemp=xxRight;justification=Justification.RIGHT;break;
}
}
else{
direction=Direction.VERTICAL;
yyTop=20*resizeRatio;yyCenter=heighttmp/2;yyBottom=heighttmp-20*resizeRatio;
xxLeft=180*(fontsize*resizeRatio/100)*((1+2/3)*n-(1/2+2/3))+20*resizeRatio;
xxCenter=widthtmp/2+180*(fontsize*resizeRatio/100)*((1+2/3)*n/2-1/2-2/3/2);
xxRight=widthtmp-180*(fontsize*resizeRatio/100)/2-20*resizeRatio;
switch(position){
case "上左":yytemp=yyTop;xxtemp=xxLeft;justification=Justification.LEFT;break;
case "上中":yytemp=yyTop;xxtemp=xxCenter;justification=Justification.LEFT;break;
case "上右":yytemp=yyTop;xxtemp=xxRight;justification=Justification.LEFT;break;
case "中左":yytemp=yyCenter;xxtemp=xxLeft;justification=Justification.CENTER;break;
case "中":yytemp=yyCenter;xxtemp=xxCenter;justification=Justification.CENTER;break;
case "中右":yytemp=yyCenter;xxtemp=xxRight;justification=Justification.CENTER;break;
case "下左":yytemp=yyBottom;xxtemp=xxLeft;justification=Justification.RIGHT;break;
case "下中":yytemp=yyBottom;xxtemp=xxCenter;justification=Justification.RIGHT;break;
case "下右":yytemp=yyBottom;xxtemp=xxRight;justification=Justification.RIGHT;break;
default:yytemp=yyBottom;xxtemp=xxRight;justification=Justification.RIGHT;break;
}
}
TextOut(photo,contents,exifFontsType,exifFontsItalic,exifFontsBold,exifFontsSize*resizeRatio,exifFontsColor,xxtemp+xx*resizeRatio,yytemp+yy*resizeRatio,justification,direction);
if(EXIFSHADOW==true){var shadowwidth=fontsize*resizeRatio/100*180*0.35;projectionstyle(shadowwidth);}
photo.activeLayer=photo.artLayers.getByName("图层 0");
photo.mergeVisibleLayers();
}
return exifDateTimeOriginal;
}

function TextOut(photo,textcontents,fonttype,fontitalic,fontbold,fontsize,fontcolor,xx,yy,justification,direction)
{
var labcolor=new SolidColor();labcolor.lab=fontcolor.lab;
var textLayer=photo.artLayers.add();
textLayer.kind=LayerKind.TEXT;
textLayer.textItem.contents=textcontents;
textLayer.textItem.direction=direction;
textLayer.textItem.justification=justification;
textLayer.textItem.position=[xx,yy];
textLayer.textItem.font=fonttype;
textLayer.textItem.fauxItalic=fontitalic;
textLayer.textItem.fauxBold=fontbold;
textLayer.textItem.size=fontsize;
textLayer.textItem.useAutoLeading=false;
textLayer.textItem.leading=textLayer.textItem.size*(1.2);
textLayer.textItem.color=labcolor;
}

function xmpMetaDataArray(item) {
var i=0;var j=0;var Count=0;
var tempString=new String(item);
var xmpArray=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){xmpArray[Count]=tempString.substr(0,i); tempString=tempString.substr(i+1,tempString.length-i-1);Count++;}
i=tempString.indexOf("<");
if(i>0){xmpArray[Count]=tempString.substr(0,i);tempString=tempString.substr(i-1,tempString.length-i+1);Count++;}
}while (tempString.indexOf("</x:xmpmeta>")>0);
xmpArray[Count]=tempString;
return xmpArray;
}

function rsOutLogoPicture(photo,logofile,position,ratio,xx,yy)
{
var logofile=new File(logofile);
var logoPhoto=open(logofile);
if(LOGOVERTICAL==true){
logoPhoto.rotateCanvas(90);
}
var logoWidth=ratio*resizeRatio;
var logoHeight=logoPhoto.height.value/logoPhoto.width.value*logoWidth;
logoPhoto.resizeImage(logoWidth,logoHeight,180,ResampleMethod.BICUBICSHARPER);
logoWidth=parseInt(logoPhoto.width);logoHeight=parseInt(logoPhoto.height);
logoPhoto.bitsPerChannel=BitsPerChannelType.SIXTEEN;
logoPhoto.convertProfile("ProPhoto RGB",Intent.RELATIVECOLORIMETRIC,false,false);
logoPhoto.selection.selectAll();
logoPhoto.selection.copy();
logoPhoto.close(SaveOptions.DONOTSAVECHANGES);
var pictureWidth=photo.width.value;var pictureHeight=photo.height.value;
var nspace=8;
var topLeftX;var topLeftY;
switch(position){
case "上左":topLeftX=0+nspace*resizeRatio;topLeftY=0+nspace*resizeRatio;break;
case "上中":topLeftX=pictureWidth/2-logoWidth/2;topLeftY=0+nspace*resizeRatio;break;
case "上右":topLeftX=pictureWidth-logoWidth-nspace*resizeRatio;topLeftY=0+nspace*resizeRatio;break;
case "中左":topLeftX=0+nspace*resizeRatio;topLeftY=pictureHeight/2-logoHeight/2;break;
case "中":topLeftX=pictureWidth/2-logoWidth/2;topLeftY=pictureHeight/2-logoHeight/2;break;
case "中右":topLeftX=pictureWidth-logoWidth-nspace*resizeRatio;topLeftY=pictureHeight/2-logoHeight/2;break;
case "下左":topLeftX=0+nspace*resizeRatio;topLeftY=pictureHeight-logoHeight-nspace*resizeRatio;break;
case "下中":topLeftX=pictureWidth/2-logoWidth/2;topLeftY=pictureHeight-logoHeight-nspace*resizeRatio;break;
case "下右":topLeftX=pictureWidth-logoWidth-nspace*resizeRatio;topLeftY=pictureHeight-logoHeight-nspace*resizeRatio;break;
default:topLeftX=pictureWidth/2-logoWidth/2;topLeftY=0+nspace*resizeRatio;break;
}
topLeftX+=xx;topLeftY+=yy;
var pointLT=Array(topLeftX,topLeftY);
var pointRT=Array(topLeftX+logoWidth,topLeftY);
var pointRB=Array(topLeftX+logoWidth,topLeftY+logoHeight);
var pointLB=Array(topLeftX,topLeftY+logoHeight);
var selRegion=Array(pointRT,pointRB,pointLB,pointLT);
photo.selection.select(selRegion);
photo.paste();
if(LOGOSHADOW==true){var shadowwidth=10*logoWidth/650;projectionstyle(shadowwidth);}
photo.activeLayer=photo.artLayers.getByName("图层 0");
photo.mergeVisibleLayers();
}

function rsJpegPhotoSave(photo,jpegfilepath,jpegquality)
{
photo.flatten();
var photoDate="";var photoTime="";
var colorspace="sRGB IEC61966-2.1";
photo.convertProfile(colorspace,Intent.PERCEPTUAL,true,false);

var filename=getfilenamestring(photo);
var JpegFileName=jpegfilepath+"\\"+filename+".JPG";
var jpgFile=File(JpegFileName);
var jpgsaveOptions=new JPEGSaveOptions();
jpgsaveOptions.embedColorProfile=true;
jpgsaveOptions.formatOptions=FormatOptions.STANDARDBASELINE;
jpgsaveOptions.matte=MatteType.WHITE;
jpgsaveOptions.scans=3;
jpgsaveOptions.quality=jpegquality;
photo.saveAs(jpgFile,jpgsaveOptions,true);
}

function getfilenamestring(photo)
{
var fileprefix="";var filesuffix="";
var temp="";var filename="";

temp=photo.name.split("-");
temp=temp[0];
temp=temp.split("@");
if(temp.length==1){filesuffix="-"+temp[0];fileprefix="";}
else if(temp.length>2){
fileprefix=temp[0]+"@";
for(i=1;i<temp.length-1;i++){filesuffix+=temp[i]+"@";}
filesuffix+=temp[i];
filesuffix="-"+filesuffix;
}
else{
fileprefix=temp[0]+"@";
if(temp[1]!=""){filesuffix="-"+temp[1];}
}
var dateArray;var timeArray;
var DateTime="";var DateTime="";
if(ExifDateTimeOriginal!=""){
dateArray=ExifDateTimeOriginal.split("T");photoDate=dateArray[0];photoTime=dateArray[1];
dateArray=photoDate.split("-");timeArray=photoTime.split(":");
if(timeArray.length==2){timeArray[2]="00";}
DateTime=dateArray[0]+dateArray[1]+dateArray[2];
DateTime=DateTime+"-"+timeArray[0]+timeArray[1]+timeArray[2];
}
else{DateTime="00000000-000000";}
filename=fileprefix+DateTime+filesuffix;
return filename;
}

function projectionstyle(borderwidth) // 添加阴影
{
var idsetd = charIDToTypeID( "setd" );
var desc5 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();var idPrpr = charIDToTypeID( "Prpr" );var idLefx = charIDToTypeID( "Lefx" );ref1.putProperty( idPrpr, idLefx );
var idLyr = charIDToTypeID( "Lyr " );var idOrdn = charIDToTypeID( "Ordn" );var idTrgt = charIDToTypeID( "Trgt" );ref1.putEnumerated( idLyr, idOrdn, idTrgt );
desc5.putReference( idnull, ref1 );
var idT = charIDToTypeID( "T " );
var desc6 = new ActionDescriptor();var idgagl = charIDToTypeID( "gagl" );var idAng = charIDToTypeID( "#Ang" );desc6.putUnitDouble( idgagl, idAng, 120.000000 );
var idScl = charIDToTypeID( "Scl " );var idPrc = charIDToTypeID( "#Prc" );desc6.putUnitDouble( idScl, idPrc, 100.000000 );
var idDrSh = charIDToTypeID( "DrSh" );var desc7 = new ActionDescriptor();var idenab = charIDToTypeID( "enab" );desc7.putBoolean( idenab, true );
var idMd = charIDToTypeID( "Md " );var idBlnM = charIDToTypeID( "BlnM" );var idMltp = charIDToTypeID( "Mltp" );desc7.putEnumerated( idMd, idBlnM, idMltp );
var idClr = charIDToTypeID( "Clr " );
var desc8 = new ActionDescriptor();var idRd = charIDToTypeID( "Rd " );desc8.putDouble( idRd, 0.000000 );
var idGrn = charIDToTypeID( "Grn " );desc8.putDouble( idGrn, 0.000000 );
var idBl = charIDToTypeID( "Bl " );desc8.putDouble( idBl, 0.000000 );
var idRGBC = charIDToTypeID( "RGBC" );desc7.putObject( idClr, idRGBC, desc8 );
var idOpct = charIDToTypeID( "Opct" );var idPrc = charIDToTypeID( "#Prc" );desc7.putUnitDouble( idOpct, idPrc, 80.000000 );
var iduglg = charIDToTypeID( "uglg" );desc7.putBoolean( iduglg, true );
var idlagl = charIDToTypeID( "lagl" );var idAng = charIDToTypeID( "#Ang" );desc7.putUnitDouble( idlagl, idAng, 135.000000 );
var idDstn = charIDToTypeID( "Dstn" );var idPxl = charIDToTypeID( "#Pxl" );desc7.putUnitDouble( idDstn, idPxl, borderwidth);
var idCkmt = charIDToTypeID( "Ckmt" );var idPxl = charIDToTypeID( "#Pxl" );desc7.putUnitDouble( idCkmt, idPxl, 10.000000 );
var idblur = charIDToTypeID( "blur" );var idPxl = charIDToTypeID( "#Pxl" );desc7.putUnitDouble( idblur, idPxl, borderwidth*1.5);
var idNose = charIDToTypeID( "Nose" );var idPrc = charIDToTypeID( "#Prc" );desc7.putUnitDouble( idNose, idPrc, 0.000000 );
var idAntA = charIDToTypeID( "AntA" );desc7.putBoolean( idAntA, true );
var idTrnS = charIDToTypeID( "TrnS" );
var desc9 = new ActionDescriptor();var idNm = charIDToTypeID( "Nm " );desc9.putString( idNm, """线性""" );
var idShpC = charIDToTypeID( "ShpC" );desc7.putObject( idTrnS, idShpC, desc9 );
var idlayerConceals = stringIDToTypeID( "layerConceals" );desc7.putBoolean( idlayerConceals, true );
var idDrSh = charIDToTypeID( "DrSh" );desc6.putObject( idDrSh, idDrSh, desc7 );
var idLefx = charIDToTypeID( "Lefx" );desc5.putObject( idT, idLefx, desc6 );
executeAction( idsetd, desc5, DialogModes.NO );
}

function partternfilling(asetstring,actnstring)
{
var idPly = charIDToTypeID( "Ply " );
var desc4 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref2 = new ActionReference();
var idActn = charIDToTypeID( "Actn" );
ref2.putName( idActn, actnstring );
var idASet = charIDToTypeID( "ASet" );
ref2.putName( idASet,asetstring );
desc4.putReference( idnull, ref2 );
executeAction( idPly, desc4, DialogModes.NO );
}
相关标签: 光圈 Resolution Exif
(0)
(0)
只看该作者
不看该作者
加入黑名单
举报
返回顶部
个人图文集
个人作品集
浙江省
浏览:724 回帖:10
第 1 页 / 共 1 页
游客没有回帖权限
泡菜
泡网分: 0.012
主题: 0
帖子: 2
注册: 2025年1月
谢谢,网盘里的可用。
不知道代码是不是你自己写的,有很大的优化空间(我11年之后就很少写代码了,现在就只剩下能看了……
(0)
(0)
只看该作者
不看该作者
加入黑名单
举报
返回顶部
个人图文集
个人作品集
湖北省
泡菜
泡网分: 7.467
主题: 48
帖子: 7232
注册: 2007年7月
年内主力装备
★ NIKON Z 8
重发一次脚本,采用“无格式文本”粘贴,还是不行,放弃!
rivershaw 编辑于 2025-03-31 03:33
(0)
(0)
只看该作者
不看该作者
加入黑名单
举报
返回顶部
个人图文集
个人作品集
浙江省
泡菜
泡网分: 7.467
主题: 48
帖子: 7232
注册: 2007年7月
年内主力装备
★ NIKON Z 8
我没想到原代码上传后,网站会识别、修改一些特殊字符。

还是老老实实改用网盘共享:

https://pan。baidu。com/s/1KkKFtvkOXc8MxeED2SV95Q?pwd=1234
rivershaw 编辑于 2025-03-31 02:58
(0)
(0)
只看该作者
不看该作者
加入黑名单
举报
返回顶部
个人图文集
个人作品集
浙江省
泡菜
泡网分: 7.467
主题: 48
帖子: 7232
注册: 2007年7月
年内主力装备
★ NIKON Z 8
南樵韵影 发表于 2025-03-30 18:21
不知道楼主测试过这个代码没有?
代码中有几个地方有错误:一个是Array[n+1]报错,二是部分地方前面有非法字符,第三是var idT = charIDToTypeID( "T " );参数报错。
你再仔细检查看看。
当然,读取Exif信息的代码效...

非常感谢指出错误。我原本想避免网盘共享,没想到上传代码后网站会对一些特殊的符号做特别处理。

再次感谢批评、指正!
(0)
(0)
只看该作者
不看该作者
加入黑名单
举报
返回顶部
个人图文集
个人作品集
浙江省
泡菜
泡网分: 0.012
主题: 0
帖子: 2
注册: 2025年1月
不知道楼主测试过这个代码没有?
代码中有几个地方有错误:一个是Array[n+1]报错,二是部分地方前面有非法字符,第三是var idT = charIDToTypeID( "T " );参数报错。
你再仔细检查看看。
当然,读取Exif信息的代码效率极低。
不知道是不是楼主自己写的?!

第一次发帖,规则不熟,各位见谅。
(0)
(0)
只看该作者
不看该作者
加入黑名单
举报
返回顶部
个人图文集
个人作品集
湖北省
泡菜
泡网分: 5.252
主题: 84
帖子: 3516
注册: 2011年5月
虽然不会用,但是要给楼主点赞!
(0)
(0)
只看该作者
不看该作者
加入黑名单
举报
返回顶部
个人图文集
个人作品集
广东省
资深泡菜
泡网分: 23.095
主题: 35
帖子: 1134
注册: 2004年11月
顶。能发个预设好的jsx插件吗?普通的就行,不大懂软件操作。谢谢!2322929920@qq.com
(0)
(0)
只看该作者
不看该作者
加入黑名单
举报
返回顶部
个人图文集
个人作品集
广东省
泡菜
泡网分: 0.423
主题: 2
帖子: 249
注册: 2024年3月
技术贴子应该获得顶赞!
(0)
(0)
只看该作者
不看该作者
加入黑名单
举报
返回顶部
个人图文集
个人作品集
广东省
泡菜
泡网分: 7.467
主题: 48
帖子: 7232
注册: 2007年7月
年内主力装备
★ NIKON Z 8

登录后可直接显示原图
(0)
(0)
只看该作者
不看该作者
加入黑名单
举报
返回顶部
个人图文集
个人作品集
浙江省
泡菜
泡网分: 7.467
主题: 48
帖子: 7232
注册: 2007年7月
年内主力装备
★ NIKON Z 8
需要各种形式的边框,请留言联系我,如有特别需求,也可以发邮件rivershaw@sina.com。

登录后可直接显示原图
(0)
(0)
只看该作者
不看该作者
加入黑名单
举报
返回顶部
个人图文集
个人作品集
浙江省
回复主题: 发个帖子,定制各种Photoshop边框
功能受限
游客无回复权限,请登录后再试