2013-03-07 61 views
-2

我需要批量重新调整大小的多个图像,这是真正简单的Photoshop中插入一个文件夹,并获得在另一个文件夹中的输出。批量调整和OUTPUT多个图像

但我需要多个图像的单个图像。

我所拥有的是所有的原始图像的每一个形象,我需要这四种递延大小的文件夹,请参阅:

+0

只做四次,每个大小一次。问题是什么? – 2013-03-07 12:48:48

+0

问题是做了四次 – mvaneijgen 2013-03-07 12:49:30

+0

请问您能详细说明一下您的问题吗? – 2013-03-07 13:08:47

回答

0

这个脚本会做你想要什么:保存了四次图像的大小需要在一个名为“出口”目录中的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);