我正在尝试为 Photoshop 找到 Java 脚本,它将根据选择裁剪为正方形,保留图像的分辨率 选择是不规则的
1 回答
1
这是一个非常简单且完全有效的问题。PhotoShop 可以通过一个功能裁剪到选择。
cropToSelection();
// crop to selection
function cropToSelection()
{
executeAction( charIDToTypeID( "Crop" ), new ActionDescriptor(), DialogModes.NO );
}
但是,如果您想要选择范围坐标,请使用:
var lb = get_selection_bounds();
// alerts current selection bounds
alert(lb[0] + ", " + lb[1] + ", " + lb[2] + ", " + lb[3] );
// function GET SELECTION BOUNDS ()
// ----------------------------------------------------------------
function get_selection_bounds()
{
// Only works with a selection
var x = parseFloat(app.activeDocument.selection.bounds[0]);
var y = parseFloat(app.activeDocument.selection.bounds[1]);
var x1 = parseFloat(app.activeDocument.selection.bounds[2]);
var y1 = parseFloat(app.activeDocument.selection.bounds[3]);
// return the results as an array
return [x, y, x1, y1];
}
于 2021-10-28T12:43:11.577 回答