我试图找到Java脚本的photoshop,这将裁剪到一个基于选择的正方形,保留图像的分辨率选择是不规则的
这是一个非常简单的问题。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];
}