Ver Mensaje Individual
  #3 (permalink)  
Antiguo 02/05/2005, 14:17
xbust3r
 
Fecha de Ingreso: noviembre-2003
Mensajes: 34
Antigüedad: 20 años, 5 meses
Puntos: 0
ahhh bueno muchas gracias!!! todo me salio ok :D solo hay un pequeño problemita en la formula pero es solo de cambiar algunos valores

function preview_img($folder,$img)
{ global $db;
$ruta="gallery/gallery/".$folder."/".$img;
$original = imagecreatefromjpeg($ruta);
$ancho = imagesx($original);
$alto = imagesy($original);
//
$picsize=150;
// Se calcula la relación alto/ancho
$aspect_ratio = $ancho / $alto;

// Se ajusta al nuevo tamaño
$new_w = $picsize;
$new_h = abs($new_w * $aspect_ratio);

if ($new_h > $picsize) {
$new_h = $picsize;
$new_w = abs($new_h * 1 / $aspect_ratio);
}
//

$thumb = imagecreatetruecolor($new_h,$new_w);
imagecopyresampled($thumb,$original,0,0,0,0,$new_h ,$new_w,$ancho,$alto);
imagejpeg($thumb,$folder."/t".$img,60);
}

asi quedo mi funcion al final el problema es q es en la funcion imagecreatetruecolor y imagecopyresampled en width debemos poner $new_h y en height $new_w para q salga correctamente

muchas gracias ;)