Posiblemente no me he expresado bien.
Les explico paso por paso:
El usuario carga la foto y después de haberla subido al servidor redimensiono la foto y la vuelvo a guardar con esto:
Código PHP:
$imagen = $_FILES['foto'.$i][name];
$ext = strtolower(end(explode(".",$_FILES['foto'.$i][name])));
$max_width = 500;
$max_height = 350;
$validext = array("jpeg","jpg","png","gif"); // Defino las extensiones válidas
$dir = '../pubfotos/';
if($ext == "jpeg" || $ext == "jpg") {
$im = imagecreatefromjpeg($path.$imagen);
$image_type = 2;
}
elseif($ext == "gif") {
$im = imagecreatefromgif($path.$imagen);
$image_type = 1;
} else {
$im = imagecreatefrompng($path.$imagen);
$image_type = 3;
}
$ancho = imagesx($im); // Ancho de la imagen
$alto = imagesy($im); // Alto
$x_ratio = $max_width / $ancho;
$y_ratio = $max_height / $alto;
if( ($ancho <= $max_width) && ($alto <= $max_height) ){
$tn_width = $ancho;
$tn_height = $alto;
}elseif (($x_ratio * $alto) < $max_height){
$tn_height = ceil($x_ratio * $alto);
$tn_width = $max_width;
}else{
$tn_width = ceil($y_ratio * $ancho);
$tn_height = $max_height;
}
$tmp = imagecreatetruecolor($tn_width,$tn_height);
imagecopyresized($tmp,$im,0,0,0,0,$tn_width, $tn_height,$ancho,$alto);
switch ($image_type)
{
case 1: imagegif($tmp, $dir.$foto[$i]);
case 2: imagejpeg($tmp, $dir.$foto[$i], 100);
case 3: imagepng($tmp, $dir.$foto[$i], 0);
default: echo ''; break;
}
Esto lo hace bien, sin problemas, la imagen es guarda redimensionada, y si la bajo a la máquina si ve perfectamente.
Ahora en otra página necesito mostrar esa imagen, pero volver a redimensionarla con un código similar. Y acá está el problema, ya que no me la muestra.
Desde ya muchas gracias, saludos
Analía