2 Replies Latest reply on Oct 31, 2011 7:48 PM by JJMack

    Square script mystery

    WmChrisHoward Level 1


      Photoshop CS5, iMac June 2010 ,8 GB Ram, OS 10.7


      Have a script, which takes any image and makes it square by comparing the height and width. Trouble is, I can run this on single images without problem, but when I try to put it in a batch the prefernces panel comes up on Units and Rulers, and does so for every single image. If I try to cancel the script it give me an error message about line 2.


      Here's the script (ExtendScript Toolkit CS5):


      var savedRuler= app.preferences.rulerUnits;

      app.preferences.rulerUnits = Units.PIXELS;

      var w = app.activeDocument.width;

      var h = app.activeDocument.height;

      if(w>h) app.activeDocument.resizeCanvas (w, w, AnchorPosition.MIDDLECENTER);

      if(w<h) app.activeDocument.resizeCanvas (h, h, AnchorPosition.MIDDLECENTER);

      //if w==h already square

      app.preferences.rulerUnits = savedRuler;


      When I tried to remove the first two lines the script stops and opens the Canvas Size dialog box, once again for each image.


      I'd liek to get this to work in a batch. Can anyone give some advice on this?


      Thanks ahead of time!