Use Python's Pillow library to calculate the proper dimensions for a resized image.
The routine
Open the image in Photoshop.
Crop the image to the desired dimensions.
Save the image.
Using ImageOps.fit()
Sample image:
Margaret Barr’s “Strange Children” [ballet], 1955 / photographer unknown https://www.flickr.com/photos/statelibraryofnsw/4944459226/ https://farm5.staticflickr.com/4118/4944459226_dfc7414a3b_o.jpg mirror: /files/images/photos/mbarr-strange-children.jpg Original 800x582
Setup
from PIL import ImageOps
from PIL import Image
img = Image.open("mbarr.jpg")
w, h = img.size
Half size
fimg = ImageOps.fit(img, (w // 2, h // 2))
fimg.save("mbarr.half.jpg")
Square
fimg = ImageOps.fit(img, (300, 300))
fimg.save("mbarr.square.jpg")
Much wider
fimg = ImageOps.fit(img, (w, h // 2))
fimg.save("mbarr.wider.jpg")
Much taller
ximg = ImageOps.fit(img, (w // 2, h))
ximg.save("mbarr.taller.jpg")
Fixed at 300x200
ximg = ImageOps.fit(img, (300, 200))
ximg.save("mbarr.300x200.jpg")