繁体   English   中英

如何在 Photoshop 脚本中获取裁剪/选择区域的偏移信息?

[英]how to get offset information of a crop/selection area in photoshop script?

当我使用“DialogModes.ALL”创建裁剪区域时,

如何在人工在 Photoshop 脚本中进行裁剪/选择操作后获取偏移信息?

谢谢 :)

var idCrop = charIDToTypeID( "Crop" );
var desc22 = new ActionDescriptor();
var idT = charIDToTypeID( "T   " );
    var desc23 = new ActionDescriptor();
    var idTop = charIDToTypeID( "Top " );
    var idPxl = charIDToTypeID( "#Pxl" );
    desc23.putUnitDouble( idTop, idPxl, 0.000000 );
    var idLeft = charIDToTypeID( "Left" );
    var idPxl = charIDToTypeID( "#Pxl" );
    desc23.putUnitDouble( idLeft, idPxl, 66.000000 );
    var idBtom = charIDToTypeID( "Btom" );
    var idPxl = charIDToTypeID( "#Pxl" );
    desc23.putUnitDouble( idBtom, idPxl, 1536.000000 );
    var idRght = charIDToTypeID( "Rght" );
    var idPxl = charIDToTypeID( "#Pxl" );
    desc23.putUnitDouble( idRght, idPxl, 1602.000000 );
var idRctn = charIDToTypeID( "Rctn" );
desc22.putObject( idT, idRctn, desc23 );
var idAngl = charIDToTypeID( "Angl" );
var idAng = charIDToTypeID( "#Ang" );
desc22.putUnitDouble( idAngl, idAng, 0.000000 );
var idDlt = charIDToTypeID( "Dlt " );
desc22.putBoolean( idDlt, false );
var idcropAspectRatioModeKey = stringIDToTypeID( "cropAspectRatioModeKey" );
var idcropAspectRatioModeClass = stringIDToTypeID( "cropAspectRatioModeClass" );
var idtargetSize = stringIDToTypeID( "targetSize" );
desc22.putEnumerated( idcropAspectRatioModeKey, idcropAspectRatioModeClass, idtargetSize );
var idWdth = charIDToTypeID( "Wdth" );
var idPxl = charIDToTypeID( "#Pxl" );
desc22.putUnitDouble( idWdth, idPxl, 800.000000 );
var idHght = charIDToTypeID( "Hght" );
var idPxl = charIDToTypeID( "#Pxl" );
desc22.putUnitDouble( idHght, idPxl, 800.000000 );
var idRslt = charIDToTypeID( "Rslt" );
var idRsl = charIDToTypeID( "#Rsl" );
desc22.putUnitDouble( idRslt, idRsl, 0.000000 );
executeAction( idCrop, desc22, DialogModes.ALL );

我可以在哪里插入一个函数来捕获人类完成作物行动后的偏移信息?

你的代码没有意义,但如果你想要选择范围,你需要一个这样的函数:

var sb = selection_bounds();


function selection_bounds()
{
   try
   {
      var x =  app.activeDocument.selection.bounds[0];
      var y =  app.activeDocument.selection.bounds[1];
      var x1 = app.activeDocument.selection.bounds[2];
      var y1 = app.activeDocument.selection.bounds[3];

      var selectionBounds = [x, x1, y, y1];

      alert(selectionBounds);
      return selectionBounds;
   }
   catch (eek)
   {
      alert("no selection");
   }
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM