-2
我需要批量重新調整大小的多個圖像,這是真正簡單的Photoshop中插入一個文件夾,並獲得在另一個文件夾中的輸出。批量調整和OUTPUT多個圖像
但我需要多個圖像的單個圖像。
我所擁有的是所有的原始圖像的每一個形象,我需要這四種遞延大小的文件夾,請參閱:
我需要批量重新調整大小的多個圖像,這是真正簡單的Photoshop中插入一個文件夾,並獲得在另一個文件夾中的輸出。批量調整和OUTPUT多個圖像
但我需要多個圖像的單個圖像。
我所擁有的是所有的原始圖像的每一個形象,我需要這四種遞延大小的文件夾,請參閱:
這個腳本會做你想要什麼:保存了四次圖像的大小需要在一個名爲「出口」目錄中的gif
app.preferences.rulerUnits = Units.PIXELS;
// call the source document
var srcDoc = app.activeDocument;
var imageWidth = srcDoc.width.value;
var imageHeight = srcDoc.height.value;
var resizeRes = 72;
fileName = app.activeDocument.name;
docName = fileName.substring(0,fileName.length -4);
//turn it RGB
var id60 = charIDToTypeID("CnvM");
var desc12 = new ActionDescriptor();
var id61 = charIDToTypeID("T ");
var id62 = charIDToTypeID("RGBM");
desc12.putClass(id61, id62);
executeAction(id60, desc12, DialogModes.NO);
// create directory called export
var myExportDir = "export"
var myDirectoryName = srcDoc.path + "/" + myExportDir;
var myDirectory = new Folder(myDirectoryName);
if(!myDirectory.exists) myDirectory.create();
// define the array to hold the sizes of the shrunk images
var reSizeArr = [
[125, 70, ResampleMethod.BICUBIC],
[640, 360, ResampleMethod.BICUBIC],
[320, 180, ResampleMethod.BICUBIC],
[1005, 565, ResampleMethod.BICUBIC],
]
for (var i=0; i<reSizeArr.length; i++)
{
var shrinkWidth = reSizeArr [i][0];
var shrinkHeight = reSizeArr [i][1];
var mySaveName = shrinkWidth + "x" + shrinkHeight;
var resizeMethod = reSizeArr [i][2];
// duplicate image into new document
// =======================================================
var id428 = charIDToTypeID("Dplc");
var desc92 = new ActionDescriptor();
var id429 = charIDToTypeID("null");
var ref27 = new ActionReference();
var id430 = charIDToTypeID("Dcmn");
var id431 = charIDToTypeID("Ordn");
var id432 = charIDToTypeID("Frst");
ref27.putEnumerated(id430, id431, id432);
desc92.putReference(id429, ref27);
var id433 = charIDToTypeID("Nm ");
desc92.putString(id433, mySaveName);
executeAction(id428, desc92, DialogModes.NO);
// resize image
activeDocument.resizeImage(shrinkWidth, shrinkHeight, resizeRes, resizeMethod);
// set to 256 cols
var id111 = charIDToTypeID("CnvM");
var desc23 = new ActionDescriptor();
var id112 = charIDToTypeID("T ");
var desc24 = new ActionDescriptor();
var id113 = charIDToTypeID("Plt ");
var id114 = charIDToTypeID("ClrP");
var id115 = charIDToTypeID("Exct");
desc24.putEnumerated(id113, id114, id115);
var id116 = charIDToTypeID("FrcC");
var id117 = charIDToTypeID("FrcC");
var id118 = charIDToTypeID("None");
desc24.putEnumerated(id116, id117, id118);
var id119 = charIDToTypeID("Trns");
desc24.putBoolean(id119, false);
var id120 = charIDToTypeID("IndC");
desc23.putObject(id112, id120, desc24);
executeAction(id111, desc23, DialogModes.NO);
// Set filePath and fileName to source path
filePath = srcDoc.path + "/" + myExportDir + "/" + mySaveName + ".gif";
// save out the image
var gifFile = new File(filePath);
gifSaveOptions = new GIFSaveOptions();
gifSaveOptions.colors = 256;
gifSaveOptions.dither = Dither.NONE;
gifSaveOptions.matte = MatteType.NONE;
gifSaveOptions.preserveExactColors = 0;
gifSaveOptions.transparency = 1;
activeDocument.saveAs(gifFile, gifSaveOptions, false, Extension.LOWERCASE);
// close that saved gif
app.activeDocument.close()
}
//close without saving
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
只做四次,每個大小一次。問題是什麼? – 2013-03-07 12:48:48
問題是做了四次 – mvaneijgen 2013-03-07 12:49:30
請問您能詳細說明一下您的問題嗎? – 2013-03-07 13:08:47