...allora prova così:

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(
$new_width>$max_upload_width){   
                 
$new_width $max_upload_width;   
                 
$new_height round($new_width/$proportions);   
             }         
             if(
$new_height>$max_upload_height){   
                 
$new_height $max_upload_height;   
                 
$new_width round($new_height*$proportions);   
              }