Created
November 2, 2011 11:48
-
-
Save moluapple/1333451 to your computer and use it in GitHub Desktop.
PS_Merge Multiple Single-Channel-Files to One Multi-Channels File
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function (){ | |
var f = Folder.selectDialog ('选择文件夹'), | |
fA = f.getFiles ('*.tif'), | |
fs = f.fsName, | |
op = new TiffSaveOptions, | |
i = 0; | |
op.imageCompression = TIFFEncoding.TIFFLZW; // 设置LZW压缩 | |
for (; i < fA.length; i += 5){ | |
process (fA[i]); | |
} | |
function process (base) { | |
var fn = base.name.split('_')[0], | |
PMS = unescape(f.getFiles (fn + '*.tif').toString().match(/(Pantone.+?)\.tif/)[1]), | |
F = function (str){return File(fs + '/' + fn + '_' + str +'.tif')}, | |
_C = F('Cyan'), | |
_M = F('Magenta'), | |
_Y = F('Yellow'), | |
_K = F('Black'), | |
_S = F(PMS), | |
loop = [_M, _Y, _K, _S], | |
mDoc = app.open(_C), | |
i = 0, | |
doc; | |
mDoc.changeMode(ChangeMode.MULTICHANNEL); | |
for (; i < 4; i++){ | |
doc = app.open(loop[i]); | |
doc.channels[0].duplicate (mDoc); | |
doc.close(SaveOptions.DONOTSAVECHANGES); | |
} | |
mDoc.channels[4].name = PMS.toUpperCase(); | |
mDoc.channels[4].kind = ChannelType.SPOTCOLOR; | |
setPMSColor(PMS); | |
mDoc.changeMode(ChangeMode.CMYK); | |
mDoc.saveAs(F('合并'), op); | |
mDoc.close(SaveOptions.DONOTSAVECHANGES); | |
} | |
// ScriptingListenerJS Code | |
function setPMSColor(str) { | |
var idsetd = charIDToTypeID("setd"); | |
var desc20 = new ActionDescriptor(); | |
var idnull = charIDToTypeID("null"); | |
var ref12 = new ActionReference(); | |
var idChnl = charIDToTypeID("Chnl"); | |
var idOrdn = charIDToTypeID("Ordn"); | |
var idTrgt = charIDToTypeID("Trgt"); | |
ref12.putEnumerated(idChnl, idOrdn, idTrgt); | |
desc20.putReference(idnull, ref12); | |
var idT = charIDToTypeID("T "); | |
var desc21 = new ActionDescriptor(); | |
var idClr = charIDToTypeID("Clr "); | |
var desc22 = new ActionDescriptor(); | |
var idBk = charIDToTypeID("Bk "); | |
desc22.putString(idBk, "PANTONE? solid coated"); | |
var idNm = charIDToTypeID("Nm "); | |
desc22.putString(idNm, str); | |
var idbookID = stringIDToTypeID("bookID"); | |
desc22.putInteger(idbookID, 3002); | |
var idbookKey = stringIDToTypeID("bookKey"); | |
desc22.putData(idbookKey, ' ' + str.replace(/\s/g, '').replace(/pantone/i, '')); | |
var idBkCl = charIDToTypeID("BkCl"); | |
desc21.putObject(idClr, idBkCl, desc22); | |
var idSCch = charIDToTypeID("SCch"); | |
desc20.putObject(idT, idSCch, desc21); | |
executeAction(idsetd, desc20, DialogModes.NO); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment