Adobe Photoshop 脚本 - 如何 Select 当前 Selection 周围的边界框?
Adobe Photoshop Scripting - How to Select Bounding Box Around Current Selection?
有谁知道在 Photoshop 扩展脚本中是否可以将不规则选区(例如魔术棒工具选区)转换为包含选区顶部、左侧、底部和右侧边界的矩形选区?
在这里,我已经记录了代码,以便您以后需要时可以修改它。另外,查看 Photoshop 的 JS 参考手册的第 166 页和后续内容,您可以阅读更多关于选择的内容 - 您可以设置羽化,extend/intersect/etc。如果需要,请选择。
为 CS6 制作,应与后者一起使用。
#target photoshop
if (documents.length == 0) {
alert("nothing opened");
} else {
// start
//setup
var file = app.activeDocument;
var selec = file.selection;
//run
var bnds = selec.bounds; // get the bounds of current selection
var // save the particular pixel values
xLeft = bnds[0],
yTop = bnds[1],
xRight = bnds[2],
yBottom = bnds[3];
var newRect = [ [xLeft,yTop], [xLeft,yBottom], [xRight,yBottom], [xRight,yTop] ]; // set coords for selection, counter-clockwise
selec.deselect;
selec.select(newRect);
// end
}
有谁知道在 Photoshop 扩展脚本中是否可以将不规则选区(例如魔术棒工具选区)转换为包含选区顶部、左侧、底部和右侧边界的矩形选区?
在这里,我已经记录了代码,以便您以后需要时可以修改它。另外,查看 Photoshop 的 JS 参考手册的第 166 页和后续内容,您可以阅读更多关于选择的内容 - 您可以设置羽化,extend/intersect/etc。如果需要,请选择。
为 CS6 制作,应与后者一起使用。
#target photoshop
if (documents.length == 0) {
alert("nothing opened");
} else {
// start
//setup
var file = app.activeDocument;
var selec = file.selection;
//run
var bnds = selec.bounds; // get the bounds of current selection
var // save the particular pixel values
xLeft = bnds[0],
yTop = bnds[1],
xRight = bnds[2],
yBottom = bnds[3];
var newRect = [ [xLeft,yTop], [xLeft,yBottom], [xRight,yBottom], [xRight,yTop] ]; // set coords for selection, counter-clockwise
selec.deselect;
selec.select(newRect);
// end
}