What is layered image? The psd I uploaded is just for testing.
I do apologize, I had overlooked the psd in the original post.
// 2025, use it at your own risk;
if (app.documents.length > 0) {
if (hasLayerMask () == true) {
var desc = new ActionDescriptor();
var ref = new ActionReference();
ref.putEnumerated(charIDToTypeID("Chnl"), charIDToTypeID("Chnl"), charIDToTypeID("Msk "));
desc.putReference(charIDToTypeID("null"), ref);
desc.putBoolean(charIDToTypeID("MkVs"), false );
executeAction(charIDToTypeID("slct"), desc, DialogModes.NO );
// load transparency;
var desc5 = new ActionDescriptor();
var ref1 = new ActionReference();
var idchannel = stringIDToTypeID( "channel" );
var idselection = stringIDToTypeID( "selection" );
ref1.putProperty( idchannel, idselection );
desc5.putReference( stringIDToTypeID( "null" ), ref1 );
var ref2 = new ActionReference();
ref2.putEnumerated( idchannel, idchannel, stringIDToTypeID( "transparencyEnum" ) );
desc5.putReference( stringIDToTypeID( "to" ), ref2 );
executeAction( stringIDToTypeID( "set" ), desc5, DialogModes.NO );
// load layer mask;
var desc7 = new ActionDescriptor();
var ref3 = new ActionReference();
ref3.putEnumerated( idchannel, stringIDToTypeID( "ordinal" ), stringIDToTypeID( "targetEnum" ) );
desc7.putReference( stringIDToTypeID( "null" ), ref3 );
var ref4 = new ActionReference();
ref4.putProperty( idchannel, idselection );
desc7.putReference( stringIDToTypeID( "with" ), ref4 );
executeAction( stringIDToTypeID( "interfaceIconFrameDimmed" ), desc7, DialogModes.NO );
// check selection;
try {activeDocument.selection.bounds;
alert ("pixels")
}
catch (e) {alert ("empty")}
}
};
////// has layer mask //////
function hasLayerMask () {
var m_Dsc01, m_Ref01;
m_Ref01 = new ActionReference();
m_Ref01.putEnumerated(stringIDToTypeID("layer"), charIDToTypeID("Ordn"), charIDToTypeID("Trgt"));
m_Dsc01 = executeActionGet(m_Ref01);
return m_Dsc01.hasKey(charIDToTypeID("Usrs"));
};