嘿所有,所以我有这个脚本,可以在Photoshop中将EPS文件转换为Tiff。
目前,它允许您选择要转换的文件的文件夹,并为Tiff文件创建一个新文件夹。我曾尝试在同一个文件夹中创建Tiff而不创建额外的文件夹,但这似乎与原始EPS文件混乱。转换发生得很好但它正在从EPS中取出数据并将其保存为空白文件。由于我将新转换的Tiff文件放在一个文件夹中,因此我在那里创建了原始EPS的副本,我不需要。
基本上我需要将文件夹中的所有EPS文件转换为Tiffs,但不想弄乱原始EPS并且不想要额外的文件副本。
我目前的剧本如下:
#include "~/AppData/Local/wbmUtils/lib/underscore.js";
//-------------- declare measurement in pixels and declare vars for HxW --------------\\
app.preferences.rulerUnits = Units.PIXELS;
var height =0;
var width = 0;
//-------------- select input and output folders --------------\\
alert("Choose a folder of EPS's");
var inPath = Folder.selectDialog();
var outPath = inPath+'/Tiffs';
$.writeln(inPath);
$.writeln(outPath);
//-------------- get full image list from input folder --------------\\
var inputs = getImageList (inPath);
function getImageList (dirPath)
{
var contents = dirPath.getFiles();
var imageList=[];
_.each(contents, function(item)
{
imageList.push(item.toString());
})
return imageList;
}
//-------------- create new folder for files --------------\\
$.writeln(inputs);
var imageFolderName = outPath;
var imageFolder = Folder(imageFolderName);
if(!imageFolder.exists) imageFolder.create();
_.each(inputs, function(input)
{
$.writeln("height: " + height + " width: " + width);
var imgWithExt = _.last(input.split('/'))
doPreviews(input, imageFolderName +'/' + imgWithExt);
var of = new File(input);
of.copy (imageFolderName +'/' + imgWithExt.split('.')[0] + '.eps');
})
//-------------- main conversion function --------------\\
function doPreviews(input, output)
{
var idOpn = charIDToTypeID("Opn ");
var desc4 = new ActionDescriptor();
var idnull = charIDToTypeID("null");
desc4.putPath(idnull, new File(input));
var idAs = charIDToTypeID("As ");
var desc5 = new ActionDescriptor();
var idRslt = charIDToTypeID("Rslt");
var idRsl = charIDToTypeID("#Rsl");
desc5.putUnitDouble(idRslt, idRsl, 300.000000);
var idAntA = charIDToTypeID("AntA");
desc5.putBoolean(idAntA, true);
var idEPSG = charIDToTypeID("EPSG");
desc4.putObject(idAs, idEPSG, desc5);
executeAction(idOpn, desc4, DialogModes.NO);
var idMk = charIDToTypeID("Mk ");
var desc7 = new ActionDescriptor();
var idnull = charIDToTypeID("null");
var ref1 = new ActionReference();
var idDcmn = charIDToTypeID("Dcmn");
ref1.putClass(idDcmn);
desc7.putReference(idnull, ref1);
var idUsng = charIDToTypeID("Usng");
var ref2 = new ActionReference();
var idHstS = charIDToTypeID("HstS");
var idCrnH = charIDToTypeID("CrnH");
ref2.putProperty(idHstS, idCrnH);
desc7.putReference(idUsng, ref2);
executeAction(idMk, desc7, DialogModes.NO);
height = app.activeDocument.height;
width = app.activeDocument.width;
if (height > width)
{
$.writeln("IS HIGHER THAN WIDE");
var idImgS = charIDToTypeID("ImgS");
var desc8 = new ActionDescriptor();
var idHght = charIDToTypeID("Hght");
var idPxl = charIDToTypeID("#Pxl");
desc8.putUnitDouble(idHght, idPxl, 6500.000000);
var idscaleStyles = stringIDToTypeID("scaleStyles");
desc8.putBoolean(idscaleStyles, true);
var idCnsP = charIDToTypeID("CnsP");
desc8.putBoolean(idCnsP, true);
var idIntr = charIDToTypeID("Intr");
var idIntp = charIDToTypeID("Intp");
var idautomaticInterpolation = stringIDToTypeID("automaticInterpolation");
desc8.putEnumerated(idIntr, idIntp, idautomaticInterpolation);
executeAction(idImgS, desc8, DialogModes.NO);
} else {
$.writeln("IS WIDER THAN HIGH");
var idImgS = charIDToTypeID("ImgS");
var desc32 = new ActionDescriptor();
var idWdth = charIDToTypeID("Wdth");
var idPxl = charIDToTypeID("#Pxl");
desc32.putUnitDouble(idWdth, idPxl, 6500.000000);
var idscaleStyles = stringIDToTypeID("scaleStyles");
desc32.putBoolean(idscaleStyles, true);
var idCnsP = charIDToTypeID("CnsP");
desc32.putBoolean(idCnsP, true);
var idIntr = charIDToTypeID("Intr");
var idIntp = charIDToTypeID("Intp");
var idautomaticInterpolation = stringIDToTypeID("automaticInterpolation");
desc32.putEnumerated(idIntr, idIntp, idautomaticInterpolation);
executeAction(idImgS, desc32, DialogModes.NO);
}
var idMk = charIDToTypeID("Mk ");
var desc20 = new ActionDescriptor();
var idnull = charIDToTypeID("null");
var ref4 = new ActionReference();
var idDcmn = charIDToTypeID("Dcmn");
ref4.putClass(idDcmn);
desc20.putReference(idnull, ref4);
var idUsng = charIDToTypeID("Usng");
var ref5 = new ActionReference();
var idHstS = charIDToTypeID("HstS");
var idCrnH = charIDToTypeID("CrnH");
ref5.putProperty(idHstS, idCrnH);
desc20.putReference(idUsng, ref5);
executeAction(idMk, desc20, DialogModes.NO);
var idCls = charIDToType("Cls ");
executeAction(idCls, desc20, DialogModes.NO);
//-------------- tiff options --------------\\
tiffSaveOptions = new TiffSaveOptions();
tiffSaveOptions.byteOrder = ByteOrder.MACOS;
tiffSaveOptions.layers = false;
tiffSaveOptions.transparency = true;
tiffSaveOptions.alphaChannels = true;
tiffSaveOptions.embedColorProfile = false;
tiffSaveOptions.imageCompression = TIFFEncoding.TIFFLZW;
tiffSaveOptions.saveImagePyramid = false;
app.activeDocument.saveAs(File(output.split('.')[0]+'.tiff'), tiffSaveOptions, true);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
}
//-------------- success message --------------\\
alert("ALL DONE!")
答案 0 :(得分:0)
我倾向于使用安装在大多数Linux发行版上的 ImageMagick 来实现这一点,并且可用于OSX和Windows。
所以,在终端的命令行:
mkdir TIFFs # Make the output directory called "TIFFs"
mogrify -format tif -path TIFFs *.eps # Convert all EPS to TIFFs/*.tif