Ver Mensaje Individual
  #4 (permalink)  
Antiguo 21/11/2009, 16:06
easy
 
Fecha de Ingreso: diciembre-2008
Mensajes: 454
Antigüedad: 15 años, 4 meses
Puntos: 2
Respuesta: redimensionar imagen proporcional

aqui te paso un codigo que he venido utilizando y me pone la imagen proporcionalmente

Código PHP:
$anchura=180;
$hmax=180;
$nombre=basename($_GET['image']);
$datos getimagesize($nombre);
if(
$datos[2]==1){$img = @imagecreatefromgif($nombre);}
if(
$datos[2]==2){$img = @imagecreatefromjpeg($nombre);}
if(
$datos[2]==3){$img = @imagecreatefrompng($nombre);}
$ratio = ($datos[0] / $anchura);
$altura = ($datos[1] / $ratio);
if(
$altura>$hmax){$anchura2=$hmax*$anchura/$altura;$altura=$hmax;$anchura=$anchura2;}
$thumb imagecreatetruecolor($anchura,$altura);
imagecopyresampled($thumb$img0000$anchura$altura$datos[0], $datos[1]);
if(
$datos[2]==1){header("Content-type: image/gif"); imagegif($thumb);}
if(
$datos[2]==2){header("Content-type: image/jpeg");imagejpeg($thumb);}
if(
$datos[2]==3){header("Content-type: image/png");imagepng($thumb); }
imagedestroy($thumb); 
Para llamara al script se hace asi:

Código HTML:
<img src="redimensionar.php?image=image /> 
yo utlizo el script dentro del archivo donde subo las imagenes, si lo haces igual, debes entonces llamarlo asi:

Código HTML:
<img src="archivo/redimensionar.php?image=image /> 
Saludos y espero te ayude

P.D.: yo lo utilizo via bd