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!
Try adding this as the first line.....
app.displayDialogs = DialogModes.NO;
You also need the first two lines or you need to retrieve the ruler units to make sure your if statements will do what you want. For if ruler units is set to percent width will always be 100% and height will always be 100% w will = y and the document may or may not be square. If the document contains a background layer you may also want to set the color its added canvas will be.