Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
how to get offset information of a crop/selection area in photoshop script?

When I use "DialogModes.ALL" to create a crop area,

How to get offset information after crop/selection action done by human in photoshop script ?

thanks :)

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 );

Where Can I insert a function for catch the offset information after crop action done by human?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You're code makes no sense, but if you want the selection bounds you'll need a function like this:

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");
   }
}
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!