How to paste clipboard into a channel using a photoshop script?
I'm trying to create a image RGB or CMYK using separate greyscale documents for each channel. My current code copy all from greyscale document and paste in a new document creating a new layer for eachone. I don't want that, I want copy from each document and paste into eachone channels new document, same as manual way, selecting each channel and clicking Edit->paste->paste especial->paste in place.
// Loop to copy each separate channel into a new merged document
for (var doc_index = 0; doc_index < 3; doc_index++ ){
//Switch documents
app.activeDocument = split_channels[0];
// copy active layer from separate channel document
app.activeDocument.selection.selectAll();
app.activeDocument.selection.copy();
// close document whithout save
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES);
//select activeDocument
app.activeDocument = mergedDoc;
// reference to whole channels
//var channelIndex = doc_index;
var myChannels = app.activeDocument.channels;
// the channel must be visible to paste greyscale layer
myChannels[doc_index].visible= true;
// turn off the rest of channels
for (var secondaryIndex = 0; secondaryIndex < myChannels.length; secondaryIndex++) {
if (doc_index != secondaryIndex) {
myChannels[secondaryIndex].visible= false
}
}
//paste layer for each new document channel (no works correctly)
app.activeDocument.paste();
//reset the channel count after copy and close each document
var split_channels = app.documents;
}thanks a lot for any suggestion.
