0
votes

Given a height and width. how can i resize the image to contain into my maximum holder for that image but maintaining aspect ratio?

2

2 Answers

3
votes

use your mathmatics

this will help

enter image description here

2
votes

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