Les paso mi secreto, ni tanto que lo saque de PHP.net
Código PHP:
<?
$img=$tal['imagen']; // Link para la imagen
$maxwidth = "350"; // Tamaño máximo de ancho
$maxheight= "160"; // Tamaño máximo de alto
$imagehw = GetImageSize($img); // recogen información del tamaño de la imagen
$imagewidth = $imagehw[0]; // se recoge el ancho
$imageheight = $imagehw[1]; // se recoge el alto
IF ($imagewidth > $maxwidth) { $alto=$imageheight/2; $ancho=$imagewidth/2; } ELSE { $ancho=$imagewidth; }
IF ($imageheight > $maxheight) { $alto=$imageheight/2; $ancho=$imagewidth/2; } ELSE { $alto=$imageheight; }
echo "<img src='$img' align='center' width='$ancho' height='$alto'>"; // se recoge y plasma la imagen ?>