Código PHP:
if($datos[0] > $ancho_max or $datos[1] > $alto_max) {
$alto = ($datos[1] / $ratio);
if($alto > $alto_max) {
$ancho=$alto_max*$ancho_max/$alto;
$alto=$alto_max;
$ancho_max=$ancho;
}
$thumb = imagecreatetruecolor($ancho_max,$alto);
imagecopyresampled($thumb, $img, 0, 0, 0, 0, $ancho_max, $alto, $datos[0], $datos[1]);
} else $thumb = &$img; //Si no se hace la redimension, hacemos que el $thumb sea la misma imagen
Un saludo,