Copy link to clipboard
Copied
I have binary mask image. What the most convenient way to make selection with form of this mask?
Copy link to clipboard
Copied
If I understood correctly, then you can make a selection from the mask like this
app.activeDocument.selection.deselect();
app.runMenuItem(stringIDToTypeID("addUserMaskToSelection"));
Copy link to clipboard
Copied
This works but there is also a step which i make with hands (Layer Mask > From Transparence). How do i made it in script?
Copy link to clipboard
Copied
selection_from_channel("Trsp");
//selection_from_channel("Msk ");
function selection_from_channel(ch_name)
{
try {
var d = new ActionDescriptor();
var r1 = new ActionReference();
var r2 = new ActionReference();
r1.putProperty( charIDToTypeID( "Chnl" ), charIDToTypeID( "fsel" ) );
r2.putEnumerated( charIDToTypeID( "Chnl" ), charIDToTypeID( "Chnl" ), charIDToTypeID( ch_name ) );
d.putReference( charIDToTypeID( "null" ), r1 );
d.putReference( charIDToTypeID( "T " ), r2 );
executeAction( charIDToTypeID( "setd" ), d, DialogModes.NO );
}
catch(e) { alert(e);}
}
Also can use 4-chars names
"RGB "
"Rd "
"Grn "
"Bl "
"Lab "
"Lght"
"A "
"B "
"CMYK"
"Cyn "
"Mgnt"
"Yllw"
"Blck"