在进行第一次选择时在photoshop中裁剪多个打开的文档



我正在制作的脚本应该这样做PDF到psd(可以)所有文档保持打开状态(好)用户在Photoshop中为每个打开的文档选择定义裁剪的内容(不确定)关闭并保存在其他文件夹中(可以)

我们的想法是,我们有pdf,我们会以某种方式裁剪。但下一次我们将有其他PDF,必须以不同的方式裁剪。这就是我到目前为止所得到的,但它像参数中的一组一样裁剪文档。

感谢

 //PDFOpenOptions.jsx
        var OpenAIFile = new PDFOpenOptions;
        OpenAIFile.antiAlias = false;
        OpenAIFile.mode = OpenDocumentMode.CMYK;
        OpenAIFile.resolution = 150;
    var myFolder = Folder.selectDialog("select folder");
    if(myFolder != null)
    {
      var fileList = myFolder.getFiles(/.(pdf)$/i);
      for(var i = 0 ;i < fileList.length; i++)
      {
        if(fileList[i] instanceof File)
        {
          var doc= open(fileList[i],OpenAIFile);
        }
      }
    };
var outputFolder = Folder.selectDialog("Dossier de destination:");
//alert(outputFolder);
if (app.documents.length > 0) {
//flatten the active document
app.activeDocument.flatten();

//jpeg options
var myJPEGOptions = new JPEGSaveOptions();
myJPEGOptions.embedColorProfile = true;
myJPEGOptions.formatOptions = FormatOptions.STANDARDBASELINE;
myJPEGOptions.matte = MatteType.WHITE;
myJPEGOptions.quality = 12;
myJPEGOptions.scans = 3;
// get documents;
var docs = app.documents;
for (var m = 0; m < app.documents.length; m++) {
app.activeDocument = docs[m];
try {
//crop 1Lsquaire-got from script lisner
var idCrop = charIDToTypeID( "Crop" );
var desc4 = new ActionDescriptor();
var idT = charIDToTypeID( "T   " );
    var desc5 = new ActionDescriptor();
    var idTop = charIDToTypeID( "Top " );
    var idPxl = charIDToTypeID( "#Pxl" );
    desc5.putUnitDouble( idTop, idPxl, 601.000000 );
    var idLeft = charIDToTypeID( "Left" );
    var idPxl = charIDToTypeID( "#Pxl" );
    desc5.putUnitDouble( idLeft, idPxl, 2068.000000 );
    var idBtom = charIDToTypeID( "Btom" );
    var idPxl = charIDToTypeID( "#Pxl" );
    desc5.putUnitDouble( idBtom, idPxl, 2948.000000 );
    var idRght = charIDToTypeID( "Rght" );
    var idPxl = charIDToTypeID( "#Pxl" );
    desc5.putUnitDouble( idRght, idPxl, 2918.000000 );
var idRctn = charIDToTypeID( "Rctn" );
desc4.putObject( idT, idRctn, desc5 );
var idAngl = charIDToTypeID( "Angl" );
var idAng = charIDToTypeID( "#Ang" );
desc4.putUnitDouble( idAngl, idAng, 0.000000 );
var idDlt = charIDToTypeID( "Dlt " );
desc4.putBoolean( idDlt, false );
var idcropAspectRatioModeKey = stringIDToTypeID( "cropAspectRatioModeKey" );
var idcropAspectRatioModeClass = stringIDToTypeID( "cropAspectRatioModeClass" );
var idtargetSize = stringIDToTypeID( "targetSize" );
desc4.putEnumerated( idcropAspectRatioModeKey, idcropAspectRatioModeClass, idtargetSize );
executeAction( idCrop, desc4, DialogModes.ALL );
//crop 1Lsquaire

//save file to folder
var myFile = new File((outputFolder ) + "/" + activeDocument.name);
app.activeDocument.saveAs(myFile, myJPEGOptions, true);
}
catch (e) {
alert ("Error the script did not execute");
}
}
while(documents.length>0){
   documents[documents.length-1].close(SaveOptions.DONOTSAVECHANGES);
}
};

如果我理解正确,您可以计算出作物坐标需要在哪里,然后根据需要应用它们。如果将脚本侦听器裁剪代码更改为可以传递这些坐标的函数。只需为第二组裁剪添加另一行,然后保存为新脚本,或者只注释掉

// usage:
selectRectangle(601, 2068, 2948, 2918);
cropToSelection();
// function SELECT RECTANGLE(top, left, bottom, right)
//
// Note: co-ordinates are same as script listener
// and not so human-friendly as t,l,r,b.
// --------------------------------------------------------
function selectRectangle(top, left, bottom, right)
{
  // deselect EVERYTHING first
  app.activeDocument.selection.deselect();
  // =======================================================
  var id1 = charIDToTypeID( "setd" );
  var desc1 = new ActionDescriptor();
  var id2 = charIDToTypeID( "null" );
  var ref1 = new ActionReference();
  var id3 = charIDToTypeID( "Chnl" );
  var id4 = charIDToTypeID( "fsel" );
  ref1.putProperty( id3, id4 );
  desc1.putReference( id2, ref1 );
  var id5 = charIDToTypeID( "T   " );
  var desc2 = new ActionDescriptor();
  var id6 = charIDToTypeID( "Top " );
  var id7 = charIDToTypeID( "#Pxl" );
  desc2.putUnitDouble( id6, id7, top );
  var id8 = charIDToTypeID( "Left" );
  var id9 = charIDToTypeID( "#Pxl" );
  desc2.putUnitDouble( id8, id9, left );
  var id10 = charIDToTypeID( "Btom" );
  var id11 = charIDToTypeID( "#Pxl" );
  desc2.putUnitDouble( id10, id11, bottom );
  var id12 = charIDToTypeID( "Rght" );
  var id13 = charIDToTypeID( "#Pxl" );
  desc2.putUnitDouble( id12, id13, right );
  var id16 = charIDToTypeID( "Rctn" );
  desc1.putObject( id5, id16, desc2 );
   executeAction( id1, desc1, DialogModes.NO );
}
function cropToSelection()
{
  executeAction( charIDToTypeID( "Crop" ), new ActionDescriptor(), DialogModes.NO );
}

最新更新