Mira a ver si esto te sirve
Código:
if isempty(max_width) then max_width = 80
if isempty(max_height) then max_height = 60
width = 300 ' Tamaño real de la imagen
height = 600 ' Tamaño real de la imagen
x_ratio = max_width / width
y_ratio = max_height / height
if (width <= max_width) AND (height <= max_height) then
tn_width = width;
tn_height = height;
elseif (x_ratio * height) < max_height then
tn_height = int(x_ratio * height)
tn_width = max_width
else
tn_width = int(y_ratio * width)
tn_height = max_height
end if
tn_width y tn_height contienen el tamaño reducido proporcional con respecto a max_width y max_height
Un saludo