Possible to Make a Photo-Paint Script to Resample and Maintain Proportions?

I recorded the script below to resample photos to a height of 1280 pixels, and a width of 844. This script works great if the images being resized are the same height and width as the original image used when the script was recorded. If the image is not the same dimensions as the one used to create the script, then the width value of 844 is inappropriate, and the images looks distorted. Is there a way to create a script to resize to 1280 pixels in height, and whatever width is needed to maintain the images original proportions?

.BitmapEffect "Automatically adjust color and contrast", "AutoEqualizeEffect "
.BitmapEffect "Unsharp Mask", CHR(7) + "UnsharpMaskEffect UnsharpMaskPerctg+AD0-100,UnsharpMaskRadius+AD0-1,UnsharpMaskThreshold+AD0-0"
.ImageResample 1280, 844, 240, 240, TRUE