Trying to test if a image/document is greater than 2 x the height
I'm creating a script that exports pdf's of selected pages or spreads to the desktop opens them in photoshop and checks if its portrait or landscape scales them based on that and exports jpgs. See code below:
if (app.activeDocument.width.value > app.activeDocument.height.value) {
//Landscape
app.activeDocument.resizeImage(
new UnitValue(2000, "px"),
currentHeight,
currentResolution,
ResampleMethod.BILINEAR
);
} else {
//Portrait
app.activeDocument.resizeImage(
new UnitValue(1325, "px"),
currentHeight,
currentResolution,
ResampleMethod.BILINEAR
);
}This works well until I run into a book that is in a landscape format. So I was thinking instead I could check if the width > 2x height. I think that should work to test if its a landscape book. Like the code below but it doesn't work.
if (app.activeDocument.width.value > (app.activeDocument.height.value * 2)) {
//Landscape
app.activeDocument.resizeImage(
new UnitValue(2650, "px"),
currentHeight,
currentResolution,
ResampleMethod.BILINEAR
);
} else{
//Portrait
app.activeDocument.resizeImage(
new UnitValue(1325, "px"),
currentHeight,
currentResolution,
ResampleMethod.BILINEAR
);
}
Any ideas of how to make this work or make it better?
