我需要批量调整多个图像的大小,这在 Photoshop 中非常容易插入一个文件夹并在另一个文件夹中获得输出。
但我需要一个图像的多个图像。
我拥有的是一个包含所有原始图像的文件夹,以及我需要四种不同尺寸的每个图像,请参阅:
我需要批量调整多个图像的大小,这在 Photoshop 中非常容易插入一个文件夹并在另一个文件夹中获得输出。
但我需要一个图像的多个图像。
我拥有的是一个包含所有原始图像的文件夹,以及我需要四种不同尺寸的每个图像,请参阅:
This script will do what you want: Save out four images in the size required as gifs in a directory called "export"
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);