I have a need for this script as well...is this the entire script? If not, can you post the complete script?
I just need to increase either the canvas width (as white area for the added width/height) or the canvas height to match the longest side of an image so they they are perfectly square. No cropping or reduction in image sizes. These are product images on white background.
Is this the full script?
var startColor = app.backgroundColor; | |
if(startColor.rgb.hexValue != 'FFFFFF'){ | |
var white = new SolidColor(); | |
white.rgb.hexValue = 'FFFFFF'; | |
app.backgroundColor = white; | |
} |
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;
if(white != undefined) app.backgroundColor = startColor;