Copy link to clipboard
Copied
Copy link to clipboard
Copied
Is the input from a set of files that you manually open?
Or is this a batch/bulk operation? If so, where are the input files located? A single folder, multiple folders?
How are the files named? They will likely be variable, but with a consistent pattern. Examples of at least two sets please.
How many files will be combined? Will the count always stay the same or will this be variable as well?
Where will the colour values come from?
Where will the filename come from?
Copy link to clipboard
Copied
Like as the attachment I provided,
four files from 4-1blu.tif to 4-4 bianco.tif,
I merged to the 4-finish.psd ,it has 4 spot channels
but i don't kwon how to use javascript to merge its .
thank your reply.
Copy link to clipboard
Copied
Please answer the questions you have been asked.
As far as I can tell you have not provided a meaningful description of the intended process so far, so please try again.
Copy link to clipboard
Copied
It seems particularly important to know how the files that belong together can be identified (and found) unequivocally.
Copy link to clipboard
Copied
The easiet way would be for you to manually select the files. But you still need to specify what order they are stacked, what spot colors are assigned, etc.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
// make multichannel and create spot channels;
// 2020, use it at your own risk;
if (documents.length > 0) {
var idto = stringIDToTypeID( "to" );
var idchannel = stringIDToTypeID( "channel" );
var idordinal = stringIDToTypeID( "ordinal" );
var iddocument = stringIDToTypeID( "document" );
var idtargetEnum = stringIDToTypeID( "targetEnum" );
var idbackground = stringIDToTypeID( "background" );
var idnull = charIDToTypeID( "null" );
var idlayer = stringIDToTypeID( "layer" );
// the file;
var myDocument = activeDocument;
var docName = myDocument.name;
try {
var basename = docName.match(/(.*)\.[^\.]+$/)[1];
var origDocPath = myDocument.fullName;
var docPath = myDocument.path;
}
catch (e) {
var basename = thedoc.name;
var docPath = "~/Desktop"
};
// look for corresponding files;
var theTifFiles = Folder(docPath).getFiles(getSomeFiles);
var theFiles = [];
var theIndex = docName.indexOf("-");
for (var m = 0; m < theTifFiles.length; m++) {
if (File(theTifFiles[m]).name.slice(0,theIndex) == docName.slice(0,theIndex) && String(theTifFiles[m]) != origDocPath){theFiles.push(theTifFiles[m])}
};
// if files found;
if (theFiles.length > 1) {
// convert to multichannel;
// =======================================================
var desc2 = new ActionDescriptor();
desc2.putClass( idto, stringIDToTypeID( "multichannelMode" ) );
executeAction( stringIDToTypeID( "convertMode" ), desc2, DialogModes.NO );
spotChannel (docName);
// open files;
for (var n = 0; n < theFiles.length; n++) {
var theFileTwo = app.open(File(theFiles[n]));
app.activeDocument = myDocument;
doCalculation(docName, theFileTwo.name);
theFileTwo.close(SaveOptions.DONOTSAVECHANGES)
};
// save psd;
saveOpts = new PhotoshopSaveOptions();
saveOpts.embedColorProfile = true;
saveOpts.alphaChannels = false;
saveOpts.layers = true;
saveOpts.spotColors = true;
myDocument.saveAs((new File(docPath+'/'+basename+'.psd')),saveOpts,false);
}
};
////// get tifs //////
function getSomeFiles (theFile) {
if (theFile.name.match(/\.(tif)$/i)) {return true};
};
////// calculation //////
function doCalculation (theFileOne, theFileTwo) {
// =======================================================
var desc3 = new ActionDescriptor(theFileOne, theFileTwo);
desc3.putClass( stringIDToTypeID( "new" ), idchannel );
var idusing = stringIDToTypeID( "using" );
var desc4 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated( idchannel, idordinal, idtargetEnum );
ref1.putProperty( idlayer, idbackground );
ref1.putName( iddocument, theFileTwo );
desc4.putReference( idto, ref1 );
var ref2 = new ActionReference();
ref2.putEnumerated( idchannel, idordinal, idtargetEnum );
ref2.putProperty( idlayer, idbackground );
ref2.putName( iddocument, theFileTwo );
desc4.putReference( stringIDToTypeID( "source2" ), ref2 );
desc3.putObject( idusing, stringIDToTypeID( "calculation" ), desc4 );
executeAction( stringIDToTypeID( "make" ), desc3, DialogModes.NO );
// change to spot channel;
spotChannel (theFileTwo);
};
////// change to spot channel //////
function spotChannel (theName) {
// =======================================================
var desc2 = new ActionDescriptor();
var ref1 = new ActionReference();
ref1.putEnumerated( idchannel, idordinal, idtargetEnum );
desc2.putReference( idnull, ref1 );
var desc3 = new ActionDescriptor();
desc3.putString( stringIDToTypeID( "name" ), theName );
desc2.putObject( idto, stringIDToTypeID( "spotColorChannel" ), desc3 );
executeAction( stringIDToTypeID( "set" ), desc2, DialogModes.NO );
};
Copy link to clipboard
Copied
thank your help .
i will learn it, if have some qustion, ask you again.
Copy link to clipboard
Copied
Thank you, I'll review the attached files when I have time.
Looking at the names, I'm guessing that English is not your native language. That is OK. Even if using translation software, please try to map out the process in a simple step by step explanation.
Copy link to clipboard
Copied
Yes,
I am a graphic designer. work in Italy.
In my work,In PS,I opened 4 same size files ,their names are different color name, them had only one gray channel, then i used channels's Panel?merge into 1 file, it include 4 spot channels with 4 color name.
Same as my attachment.
I tried to use the function "Merge" in the script,but the result is wrong ,it not make a whole, it is only used to merge a spot channel .
I need what script's function can to all files together to one file.?
? ?example:
? ? var Ref = app.activeDocument.channels.getByName("gray");
? ? Ref.merge()? //the function "Merge" for merge spot channel,not for merge channels.
Sorry, I don’t know how to provide you with a clear explanation.
If you have time, please to open my files to look it.
thank you for your reply.