You are reading a single comment by @Sumo and its replies.
Click here to read the full conversation.
-
I think this is what you're trying to do
app.preferences.rulerUnits = Units.PIXELS; var doc = activeDocument; var Orientation = parseFloat(doc.height / doc.width); if (Orientation >= 1) { var wFactorP = parseFloat(7016 / doc.width); var hFactorP = parseFloat(9933 / doc.height); if (wFactorP > hFactorP) { doc.resizeImage(7016, undefined, undefined, ResampleMethod.BICUBIC); } else { doc.resizeImage(undefined, 9933, undefined, ResampleMethod.BICUBIC) } } else if (Orientation < 1) { var wFactorL = parseFloat(9933 / doc.width) var hFactorL = parseFloat(7016 / doc.height); if (wFactorL > hFactorL) { doc.resizeImage(9933, undefined, undefined, ResampleMethod.BICUBIC) } else { doc.resizeImage(undefined, 7016, undefined, ResampleMethod.BICUBIC) } }
Can anyone help an idiot (me) with a bit of javascript? Trying to write a script that identifies whether an image is portrait or landscape orientation then scales the image so that it is at a minimum 7016 x 9933 px (or 9933 x 7016 depending on orientation...)
I think I've got the basic logic of it right but I don't know a jot about js but think in order for this to work I need to have the five lines after each if(Orientation...) condition be a block statement but can I do this whilst having another condition inside of it? If anyone could explain it to me like I'm five I'd be greatly appreciative!