如何解决使用 Photoshop 脚本选择对象
我需要能够在大量图像中自动选择人物。我知道它们的坐标、宽度和高度,但理想情况下更喜欢有一个更人性化的选择,并且通过界面的普通对象选择似乎效果很好。现在我想知道我是否可以用 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,left );
var idbottom = stringIDToTypeID( "bottom" );
var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
desc5.putUnitDouble( idbottom,bottom );
var idright = stringIDToTypeID( "right" );
var idpixelsUnit = stringIDToTypeID( "pixelsUnit" );
desc5.putUnitDouble( idright,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)获取
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。