Alla fine, pensandoci bene, l'ho semplificato io xD
Codice PHP:
<?php

function getResized($w$h)
{
    
$maxWidth 200;
    
$maxHeight 350;
    
    
$originalW $w;
    
$originalH $h;
     
    if( 
$originalW <= $maxWidth && $originalH <= $maxHeight )
    {
        
$profileTHBWidth $originalW;
        
$profileTHBHeight $originalH;
    }
    else if( 
$originalW $maxWidth || $originalH $maxHeight )
    {
        
$coeff 1;
        do
        {
            
$profileTHBWidth $originalW-(($originalW*$coeff)/100);
            
$profileTHBHeight $originalH-(($originalH*$coeff)/100);
            ++
$coeff;
        } while( (
$profileTHBWidth $maxWidth) OR ($profileTHBHeight $maxHeight) );
    }
    else { 
/*va bene*/ }

    return array(
ceil($profileTHBWidth), ceil($profileTHBHeight));
}

print_r(getResized(50002500));
?>