分享三个photoshop小脚本(JavaScript)

打包下载地址:http://u.163.com/nye9b3Q3  提取码: aWz10Oig

1、layerRename.jsx 图层批量重命名

//批量修改图层名称,输入新名称前缀
var doc =  app.activeDocument;
var newLayerName = prompt ("请输入新名称的前缀:" , doc.layers[0].name, "层命名工具");
//alert (newLayerName);
if (newLayerName != null) {
	for (i=0; i<doc.layers.length;i++)
	{
		doc.layers[i].name = newLayerName+(doc.layers.length-i);
		//隐藏图层
		//doc.layers[i].visible = false;
		//doc.layers[i].name = newLayerName+"_"+(i+1);
	}
}

2、exportLayer.jsx 单独导出所有层,default导出png格式

//批量导图(png/jpg)工具,指定保存路径
var doc =  app.activeDocument;
var savePath = prompt ("请输入保存路径:" , doc.path, "批量导出图工具");
//alert (newLayerName);
function SavePNG(saveFile, compressionValue) {
pngSaveOptions = new PNGSaveOptions();
pngSaveOptions.compression = compressionValue;
pngSaveOptions.interlaced = false;
activeDocument.saveAs(saveFile, pngSaveOptions, true,Extension.LOWERCASE);
}

/*
function SaveJPEG(saveFile, jpegQuality) {
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = jpegQuality; //1-12
activeDocument.saveAs(saveFile, jpgSaveOptions, true,Extension.LOWERCASE);
}
*/

if (savePath != null) {
	for (i=0; i<doc.layers.length;i++)
    {
        app.activeDocument.layers[i].visible = true;
        saveFile = new File(savePath+'/'+doc.layers[i].name+ '.png');
        SavePNG(saveFile, 9);
		//SaveJPEG(saveFile, 10);
        app.activeDocument.layers[i].visible = false;
    }
}

3、importSequenceAsLayer.jsx 批量导入序列并自动分配到每个图层

var seq_path = prompt ("请输入图片所在文件目录:" , "C:\\Users\\Administrator\\Desktop", "批量导入图片到图层");
var sourceFolder = Folder(seq_path);
var seq_file = sourceFolder.getFiles("*.png");

// import frist image
var currentDoc = open(new File(seq_file[0]));
currentDoc.layers[0].name = currentDoc.name;

for (var i = 1;i < seq_file.length; i++) {
	fileToLayer(seq_file[i], currentDoc);
}
saveDoc_psd(currentDoc);

//open file,rename layer, copy layer to newDoc.layer
function fileToLayer(input_file_path, newDoc) {
var file_path = new File(input_file_path);
var doc_temp = open (file_path);
doc_temp.layers[0].name = doc_temp.name;
doc_temp.layers[0].duplicate(newDoc, ElementPlacement.INSIDE);
doc_temp.close (SaveOptions.DONOTSAVECHANGES);
}

//save document psd type
function saveDoc_psd(currentDoc) {
saveFilePath = new File(currentDoc.path+'/'+currentDoc.name+ '.psd');
psdSaveOptions = new PhotoshopSaveOptions();
currentDoc.saveAs(saveFilePath,psdSaveOptions , true, Extension.LOWERCASE);
}

鉴于这方面资料少,本人愿意共享一些自己的脚本。

参考资料《Photoshop-CS6-JavaScript-Ref》、《JavaScript Tools Guide CS6》

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值