Vero: serve qualche riga in più:
Codice PHP:
// ottengo la larghezza e l'altezza dell'immagine originale
list($image_width, $image_height) = getimagesize($remote_file);
if($image_width>$max_upload_width || $image_height >$max_upload_height){
$proportions = $image_width/$image_height;
$new_width=$image_width;
$new_height=$image_height;
while($new_width>$max_upload_width || $new_height >$max_upload_height){
if($image_width>$image_height){
$new_width = $max_upload_width;
$new_height = round($max_upload_width/$proportions);
}
else{
$new_height = $max_upload_height;
$new_width = round($max_upload_height*$proportions);
}
}
per evitare un endless loop.