文档库

最新最全的文档下载
当前位置:文档库 > 脚本在找茬中的任务

脚本在找茬中的任务

#target photoshop

app.bringToFront();

res ="dialog { \

text:'找茬数据专用',\

group: Group{orientation: 'column',alignChildren:'left',\

folderO:Group{ orientation: 'row', \

b: Button {text:'待处理文件夹', properties:{name:'open'} ,helpTip:'选择您需要处理的文件所在的文件夹'},\

s: EditText { text:'', preferredSize: [360, 20] },\

},\

folderS:Group{ orientation: 'row', \

b: Button {text:'输出图像至', properties:{name:'save'} ,helpTip:'选择您处理好的文件要保存至的文件夹'},\

s: EditText { text:'', preferredSize: [300, 20] },\

},\

meng:Group{ orientation: 'row', \

c:Checkbox { text:' 启用黑色蒙版'} ,\

s: StaticText { text:'| 蒙版收缩量(单位px):' }, \

e: EditText { text:'2', preferredSize: [20, 18]},\

},\

Quality: Group { orientation: 'row', \

c:Checkbox { text:' 仅查询坐标,不生成图片'} ,\

s: StaticText { text:'| 生成JPG的压缩质量(0-100):' }, \

e: EditText { text:'70', preferredSize: [30, 18]},\

}, \

gg: Group{orientation: 'column',alignChildren:'left' },\

timeline:Progressbar{bounds:[0,0,400,10] , minvalue:0,maxvalue:100}\

aa: Button { text:'START'}, \

脚本在找茬中的任务

}\

}";

var mengPoint="";

var mengColor =new SolidColor;

mengColor.rgb.red =0;

mengColor.rgb.green =0;

mengColor.rgb.blue =0;

win = new Window (res);

win.myText = win.group.gg.add("edittext",[0,0,500,300],'~~~',{multiline:true, readonly:false});

function lyFoot() { // 选中最下层

var id553 = charIDToTypeID( "slct" );

var desc88 = new ActionDescriptor();

var id554 = charIDToTypeID( "null" );

var ref95 = new ActionReference();

var id555 = charIDToTypeID( "Lyr " );

var id556 = charIDToTypeID( "Ordn" );

var id557 = charIDToTypeID( "Back" );

ref95.putEnumerated( id555, id556, id557 );

desc88.putReference( id554, ref95 );

var id558 = charIDToTypeID( "MkVs" );

desc88.putBoolean( id558, false );

executeAction( id553, desc88, DialogModes.NO );

}

function lyUp(){ //选中上一层

var id559 = charIDToTypeID( "slct" );

var desc89 = new ActionDescriptor();

var id560 = charIDToTypeID( "null" );

var ref96 = new ActionReference();

var id561 = charIDToTypeID( "Lyr " );

var id562 = charIDToTypeID( "Ordn" );

var id563 = charIDToTypeID( "Frwr" );

ref96.putEnumerated( id561, id562, id563 );

desc89.putReference( id560, ref96 );

var id564 = charIDToTypeID( "MkVs" );

desc89.putBoolean( id564, false );

executeAction( id559, desc89, DialogModes.NO );

}

function openSm() { //打开智能对象

var id216 = stringIDToTypeID( "placedLayerEditContents" );

var desc43 = new ActionDescriptor();

executeAction( id216, desc43, DialogModes.NO );

}

function lyHidden(){ //隐藏当前图层

var id217 = charIDToTypeID( "Hd " );

var desc44 = new ActionDescriptor();

var id218 = charIDToTypeID( "null" );

var list1 = new ActionList();

var ref24 = new ActionReference();

var id219 = charIDToTypeID( "Lyr " );

var id220 = charIDToTypeID( "Ordn" );

var id221 = charIDToTypeID( "Trgt" );

ref24.putEnumerated( id219, id220, id221 );

list1.putReference( ref24 );

desc44.putList( id218, list1 );

executeAction( id217, desc44, DialogModes.NO );

}

function sm(name) { //保存结果图像

lyFoot();

openSm();

var smDoc=app.activeDocument;

if (win.group.meng.c.value) meng(smDoc);

var saveFolder = win.group.folderS.s.text+"/";

saveOptions = new ExportOptionsSaveForWeb();

saveOptions.format =SaveDocumentType.JPEG;

saveOptions.quality=win.group.Quality.e.text;

smDoc.exportDocument(new File(saveFolder + name + "_1.jpg"),ExportType.SAVEFORWEB,saveOptions);

lyHidden();

smDoc.exportDocument(new File(saveFolder + name + "_0.jpg"),ExportType.SAVEFORWEB,saveOptions);

smDoc.close(SaveOptions.DONOTSAVECHANGES);

}

function selectBounds(name,a,b,c,d) { //做选区

app.activeDocument.selection.select([[a, b],[ a, d ], [c, d], [ c, b]],SelectionType.EXTEND); }

function meng(smDoc) { //添加蒙版

nowPoint=mengPoint.split(",");

for (var i=0;i

selectBounds(smDoc,nowPoint[i],nowPoint[i+1],nowPoint[i+2],nowPoint[i+3],) }

// ==================================扩展n像素

var id32 = charIDToTypeID( "Expn" );

var desc5 = new ActionDescriptor();

var id33 = charIDToTypeID( "By " );

var id34 = charIDToTypeID( "#Pxl" );

desc5.putUnitDouble( id33, id34, Number(win.group.meng.e.text) ); executeAction( id32, desc5, DialogModes.NO );

// ==================================反选

var id35 = charIDToTypeID( "Invs" );

executeAction( id35, undefined, DialogModes.NO );

//

smDoc.selection.fill(mengColor); //填充蒙版色

}

// 打开文件夹的操作

var folderOpen=win.group.folderO

var folderSave=win.group.folderS

folderOpen.b.onClick = function() {

var defaultFolder = folderOpen.s.text;

var testFolder = new Folder(defaultFolder);

if (!testFolder.exists) {

defaultFolder = "~";

}

var selFolder = Folder.selectDialog("选择待处理文件夹", defaultFolder);

if ( selFolder != null ) {

folderOpen.s.text = selFolder.fsName;

folderOpen.s.helpTip = selFolder.fsName.toString();

}

}

folderSave.b.onClick = function() {

var defaultFolder = folderSave.s.text;

var testFolder = new Folder(defaultFolder);

if (!testFolder.exists) {

defaultFolder = "~";

}

var selFolder = Folder.selectDialog("选择要储存至的文件夹", defaultFolder);

if ( selFolder != null ) {

folderSave.s.text = selFolder.fsName;

folderSave.s.helpTip = selFolder.fsName.toString();

}

}

win.group.aa.onClick=function(){

var myText="";

var openFolder = Folder(win.group.folderO.s.text);

var fileList = openFolder.getFiles() //获取open文件夹下所有文件

win.group.timeline.value =0;

var k=100/fileList.length;

//调整文件顺序,按数字大小排序

fileList.sort(function compare(a,b){return Number(http://www.wendangku.net/doc/db032d30eefdc8d376ee322e.html.substring(0, http://www.wendangku.net/doc/db032d30eefdc8d376ee322e.html.length-4))-Number(http://www.wendangku.net/doc/db032d30eefdc8d376ee322e.html.substring(0, http://www.wendangku.net/doc/db032d30eefdc8d376ee322e.html.length-4));}) //

for (i=0;i

if (fileList[i] instanceof File && fileList[i].hidden == false){ //不处理隐藏文件

var docRef =open(fileList[i]);

var nowName =http://www.wendangku.net/doc/db032d30eefdc8d376ee322e.html.substring(0, http://www.wendangku.net/doc/db032d30eefdc8d376ee322e.html.length-4);

while (nowName.length<4) {

nowName ="0"+nowName;

}

myText +=nowName+",";

mengPoint="";

lyFoot();

for (j=1;j

lyUp();

myText+=docRef.activeLayer.bounds+",";

mengPoint+=docRef.activeLayer.bounds+",";

}

if (!win.group.Quality.c.value) sm(nowName);

docRef.close(SaveOptions.DONOTSAVECHANGES);

myText +="\r\n";

}

win.group.timeline.value =win.group.timeline.value+k;

}

var re = / px/g; //要替换的“px”

win.myText.text=myText.replace(re, "");

}

//////////////

win.center();

win.show();