使用 Photoshop 脚本选择对象

Object Selection with Photoshop scripting

我需要能够在大量图像中自动 select 人类。我知道它们的坐标、宽度和高度,但理想情况下更希望有一个更人性化的 selection,并且它似乎通过界面通过普通对象 selection 工作得很好。现在我想知道我是否可以使用 Photoshop 脚本来完成它?任何线索表示赞赏!

澄清一下,我说的是最近推出的对象选择工具 here

谢谢大家!

我设法让它工作了。如果有人感兴趣:

假设找到边界框的坐标(上、左、下、右)。

var idset = stringIDToTypeID( "set" );
var desc4 = new ActionDescriptor();
var idnull = stringIDToTypeID( "null" );

var ref3 = new ActionReference();
var idchannel = stringIDToTypeID( "channel" );
var idselection = stringIDToTypeID( "selection" );
ref3.putProperty( idchannel, idselection );
desc4.putReference( idnull, ref3 );

var idto = stringIDToTypeID( "to" );
    var desc5 = new ActionDescriptor();
    var idtop = stringIDToTypeID( "top" );
    var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
    desc5.putUnitDouble( idtop, idpixelsUnit, top );
    var idleft = stringIDToTypeID( "left" );
    var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
    desc5.putUnitDouble( idleft, idpixelsUnit, left );
    var idbottom = stringIDToTypeID( "bottom" );
    var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
    desc5.putUnitDouble( idbottom, idpixelsUnit, bottom );
    var idright = stringIDToTypeID( "right" );
    var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
    desc5.putUnitDouble( idright, idpixelsUnit, right );
    
var idrectangle = stringIDToTypeID( "rectangle" );
desc4.putObject( idto, idrectangle, desc5 );
var iddeepSelect = stringIDToTypeID( "deepSelect" );
desc4.putBoolean( iddeepSelect, true );
var idobjectSelectionMode = stringIDToTypeID( "objectSelectionMode" );
desc4.putInteger( idobjectSelectionMode, 0 );
var idmagicLassoAutoEnhance = stringIDToTypeID( "magicLassoAutoEnhance" );
desc4.putBoolean( idmagicLassoAutoEnhance, true );
var idsmartSubtract = stringIDToTypeID( "smartSubtract" );
desc4.putBoolean( idsmartSubtract, true );
executeAction( idset, desc4, DialogModes.NO );

这些代码可以通过 ScriptingListener 获取(可用here