help! save split channel

Anyone, especially newbies, asking for help with Photoshop Scripting and Photoshop Automation - as opposed to those contributing to discussion about an aspect of Photoshop Scripting

Moderators: Tom, Kukurykus

roychen

help! save split channel

Post by roychen »

i want to split channel(file)....every file must save as "File + channel name.tif"...
exmple:
file nae is jy001
channel 1 name is bl
channel 2 name is cl
channel 3 name is kl
after split channel atuo save as jy001-bl.tif/jy001-cl.tif/jy001-kl.tif(total 3 files)
pls help me

Professional AI Audio Generation within Adobe Premiere Pro - Download Free Plugin here

pfaffenbichler

help! save split channel

Post by pfaffenbichler »

Does this help?
Code: Select all// 2013, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var thePath = myDocument.path;
var basename = myDocument.name.match(/(.*)\.[^\.]+$/)[1];
var theNumber = myDocument.channels.length;
try {
// split;
// =======================================================
var idSplC = charIDToTypeID( "SplC" );
    var desc2 = new ActionDescriptor();
executeAction( idSplC, desc2, DialogModes.NO );
// save files;
for (var m = 0; m < theNumber; m++) {
var thisDocument = app.activeDocument;
var thisName = thisDocument.name;
var thisPath = thePath+"/"+basename+thisName.slice(thisName.lastIndexOf("_"), thisName.length)+".tif";
saveAsTif (thisDocument, thisPath);
thisDocument.close();
}
}
catch (e) {}
};
////// save tif //////
function saveAsTif (myDocument, thePath) {
// tif options;
tifOpts = new TiffSaveOptions();
tifOpts.embedColorProfile = true;
tifOpts.imageCompression = TIFFEncoding.TIFFLZW;
tifOpts.alphaChannels = false;
tifOpts.byteOrder = ByteOrder.MACOS;
tifOpts.layers = false;
// save copy;
myDocument.saveAs((new File(thePath)), tifOpts, false);
};
roychen

help! save split channel

Post by roychen »

pfaffenbichler wrote:Does this help?
Code: Select all// 2013, use it at your own risk;
#target photoshop
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
var thePath = myDocument.path;
var basename = myDocument.name.match(/(.*)\.[^\.]+$/)[1];
var theNumber = myDocument.channels.length;
try {
// split;
// =======================================================
var idSplC = charIDToTypeID( "SplC" );
    var desc2 = new ActionDescriptor();
executeAction( idSplC, desc2, DialogModes.NO );
// save files;
for (var m = 0; m < theNumber; m++) {
var thisDocument = app.activeDocument;
var thisName = thisDocument.name;
var thisPath = thePath+"/"+basename+thisName.slice(thisName.lastIndexOf("_"), thisName.length)+".tif";
saveAsTif (thisDocument, thisPath);
thisDocument.close();
}
}
catch (e) {}
};
////// save tif //////
function saveAsTif (myDocument, thePath) {
// tif options;
tifOpts = new TiffSaveOptions();
tifOpts.embedColorProfile = true;
tifOpts.imageCompression = TIFFEncoding.TIFFLZW;
tifOpts.alphaChannels = false;
tifOpts.byteOrder = ByteOrder.MACOS;
tifOpts.layers = false;
// save copy;
myDocument.saveAs((new File(thePath)), tifOpts, false);
};


hi pfaffenbichler
i test but can't find channel name! ....only file name+ 1 (2.3.4....)
i need file name + channel name
such as :
file name is a
channel 1 name is 1A,channel 2 name is 2B,channel 3 is kl,.....after split channel save file,file name is a-1A.tif ,a-2B.tif ,a-kl.tif ,don't a-1.tif , a-2.tif etc...
pfaffenbichler

help! save split channel

Post by pfaffenbichler »

In my test it named the resulting files correctly (the original name and the channel’s name).

Could you post a screenshot of the list of files?
roychen

help! save split channel

Post by roychen »

pfaffenbichler

help! save split channel

Post by pfaffenbichler »

At what?
roychen

help! save split channel

Post by roychen »

pls look att
pfaffenbichler

help! save split channel

Post by pfaffenbichler »

On my computer the names do not get clipped.
Could you try changing the path to
Code: Select allvar thisPath = thePath+"/"+basename+thisName.slice(thisName.lastIndexOf("_"))+".tif";
to see if that makes a difference?
roychen

help! save split channel

Post by roychen »

same.....i use pc computer
pfaffenbichler

help! save split channel

Post by pfaffenbichler »

I can’t reproduce the issue so you best trouble-shoot it yourself.

If you split the Channels manually do the resulting files have the full channel names as part of their names (even though they are unsaved)?