我需要创建一个操作,它将: 1. 在已打开的文件中复制图像的选定部分(手动选择) 2. 将选择粘贴到新文件中 3. 将新文件另存为 jpg 文件,但不使用默认值“untitled.jpg”的文件名 - 改为使用唯一名称或使用自动增量后缀
由于该操作将对同一图像的不同选择运行多次,因此使用唯一名称或自动递增后缀保存每个选择将节省每次保存不同选择时手动提供文件名的步骤。
我可以创建一个进入另存为步骤的操作,但不知道是否可以如上所述修改默认另存为名称。可能吗?
不要认为这可以通过一个动作来实现,但你可以编写一个脚本来处理它。
没有。之前尝试过,但没有成功。您必须手动保存。
我为类似的工作创建了一个脚本。它使用一种技术来生成唯一的文件名并保存文件。
/************************************************************************
* Author: Nishant Kumar
* Description: This script iterates through a template to create
* jpg images with id card numbers.
* Date: 08-03-2015
***********************************************************************/
//current id count
var id_count = 0;
//total no of id cards to produce
var total_id_cards = 42;
//no. of cards per sheet
var card_per_sheet = 21;
//Save path related to current file
var save_path = app.activeDocument.path;
//do an iteration, number the cards and save file
do{
//iterate 24 nos in each document
for(var i = 0; i<card_per_sheet; i++){
id_count++;
app.activeDocument.layers[i].textItem.contents = id_count;
}
//Create a jpg document with standard options
jpgSaveOptions = new JPEGSaveOptions();
jpgSaveOptions.embedColorProfile = true;
jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE;
jpgSaveOptions.matte = MatteType.NONE;
jpgSaveOptions.quality = 12;
//Save jpg with incremental file names (1.jpg, 2.jpg), make sure the path exists
jpgFile = new File( save_path + "/output/" + id_count/card_per_sheet + ".jpeg" );
app.activeDocument.saveAs(jpgFile, jpgSaveOptions, true, Extension.LOWERCASE);
}while(id_count < total_id_cards);
我知道这是旧的,但仍然。您可以使用以下脚本。
如何使用脚本:
将以下脚本复制到记事本中,并将其保存在类似“ C:\Program Files (x86)\Adobe\Adobe Photoshop CS2\Presets\Scripts
”的目录中,扩展名为JSX
。要在 Photoshop 中运行脚本,请转到File > Scripts > "Your Script"
.
#目标Photoshop
主要的();
函数主(){
if(!documents.length) 返回;
var Name = app.activeDocument.name.replace(/.[^.]+$/, '');
名称 = 名称.replace(/\d+$/,'');
尝试{
var savePath = activeDocument.path;
}捕捉(e){
alert("You must save this document first!");
}
var fileList= savePath.getFiles(Name +"*.jpg").sort().reverse();
var 后缀 = 0;
如果(文件列表长度){
Suffix = Number(fileList[0].name.replace(/\.[^\.]+$/, '').match(/\d+$/));
}
后缀= zeroPad(后缀 + 1, 4);
var saveFile = File(savePath + "/" + Name + "_" + Suffix + ".jpg");
保存JPG(保存文件);
}
函数 SaveJPG(saveFile){
//创建一个带有标准选项的jpg文档 jpgSaveOptions = new JPEGSaveOptions(); jpgSaveOptions.embedColorProfile = true; jpgSaveOptions.formatOptions = FormatOptions.STANDARDBASELINE; jpgSaveOptions.matte = MatteType.NONE; jpgSaveOptions.quality = 12;
//Save jpg with incremental file names (1.jpg, 2.jpg), make sure the path exists
activeDocument.saveAs(saveFile, jpgSaveOptions, true, Extension.LOWERCASE);
};
函数 zeroPad(n, s) {
n = n.toString();
而 (n.length < s) n = '0' + n;
返回 n;
};