RGBチャンネルからマスクを抽出するものを書き込もうとしています。photoshop javascript channel content
純粋なR GおよびBレイヤーとして出力されたマスクを含む多くの.exrファイルがあります。
私はこれをやった:
var doc = app.activeDocument;
function showMasks(docGroups) {
//step through the groups
for (var i=0; i<docGroups.length; i++) {
try{
//step through the layers in each group
for(layerIndex=0; layerIndex < docGroups[i].artLayers.length; layerIndex++) {
var RGB = [doc.channels.getByName('Red'),doc.channels.getByName('Green'),doc.channels.getByName('Blue')];
for(var a in RGB)
{
//create slection from channel
doc.selection.load(RGB[a], SelectionType.REPLACE);
//add new layer
doc.artLayers.add();
// REVEAL ALL from selection
var idMk = charIDToTypeID("Mk ");
var desc62 = new ActionDescriptor();
var idNw = charIDToTypeID("Nw ");
var idChnl = charIDToTypeID("Chnl");
desc62.putClass(idNw, idChnl);
var idAt = charIDToTypeID("At ");
var ref20 = new ActionReference();
var idChnl = charIDToTypeID("Chnl");
var idChnl = charIDToTypeID("Chnl");
var idMsk = charIDToTypeID("Msk ");
ref20.putEnumerated(idChnl, idChnl, idMsk);
desc62.putReference(idAt, ref20);
var idUsng = charIDToTypeID("Usng");
var idUsrM = charIDToTypeID("UsrM");
var idRvlS = charIDToTypeID("RvlS");
desc62.putEnumerated(idUsng, idUsrM, idRvlS);
executeAction(idMk, desc62, DialogModes.NO);
}
//hide layer, move on to the next
docGroups[i].artLayers[layerIndex].visible = false;
}
}
catch(e){continue;}
}
}
showMasks(doc.layerSets);
グループおよび層を介し大丈夫、手順を動作し、それに応じて上の層、マスクで新しいレイヤを出力します。ただし、レイヤーにR GとBが含まれている場合にのみ機能し、1色のレイヤーであれば停止します。 レイヤーに3つのチャンネルの色がすべて含まれていない場合、どのように動作させるかを設定しますか? または一度に1つのチャンネルを行うように書き換えますか?
任意のアイデアは感謝、感謝/ S
これを解決しました: – SEJM