Reputation: 13
Given a height and width. how can i resize the image to contain into my maximum holder for that image but maintaining aspect ratio?
Upvotes: 0
Views: 353
Reputation: 12142
Like this:
sx = original_width/destination_width
sy = original_height/destination_height
if sx*original_height > destination_height:
s = sy
else:
s = sx
new_width = original_width*s
new_height = original_height*s
Upvotes: 2