Ver Mensaje Individual
  #1 (permalink)  
Antiguo 14/11/2011, 12:28
fernandrock
 
Fecha de Ingreso: diciembre-2010
Mensajes: 17
Antigüedad: 13 años, 4 meses
Puntos: 0
Problemas al redimensionar imagen con php, aparece todo negro

Hola amigos!

Tengo el siguiente codigo y redimenciona bien como yo quiero, pero algunas imagenes no se por que simplemente las muestra en negro.

Les dejo el codigo para que lo revisen y me puedan ayudar porfa

Código PHP:
<?
$amax
=150;
$hmax=120;
$anchura $amax;
$nombre$_GET['i'];
$nombreFalse "./images/image_error.jpg";
if(
$nombre != ""){
    
$datos getimagesize($nombre);
    if(
$datos[2]==1){
        
$img imagecreatefromgif($nombre);
    }else if(
$datos[2]==2){
        
$img imagecreatefromjpeg($nombre);
    }else if(
$datos[2]==3){
        
$img imagecreatefrompng($nombre);
    }else{
        
$img imagecreatefromjpeg($nombre);
    }
    
$ratio = ($datos[0] / $amax);
$altura = ($datos[1] / $ratio);
    if(
$altura $hmax){
        
$anchura2 round($hmax*$anchura/$altura0);
        
$altura $hmax;
        
$anchura $anchura2;
    }
    
$thumb imagecreatetruecolor($amax$hmax);
    
$posX = ($amax/2)-($anchura/2);
    
$posY = ($hmax/2)-($altura/2);
//    imagecopyresampled(destino, procedencia, x, y, procx, procy, anchuro_salida, alto_salida, ancho_proc, alto_proc)
    
imagecopyresampled($thumb$img$posX$posY00$anchura$altura$datos[0], $datos[1]);
    if(
$datos[2]==1){
        
header("Content-type: image/gif");
        
imagegif($thumb,$thumb,50);
    }else if(
$datos[2]==2){
        
header("Content-type: image/jpeg");
        
imagejpeg($thumb);
    }else if(
$datos[2]==3){
        
header("Content-type: image/png");
        
imagepng($thumb);
    }
    
imagedestroy($thumb);
}else{
    
$img imagecreatefromjpeg($nombreFalse);
    
$thumb imagecreatetruecolor(150,120);
    
imagecopyresampled($thumb$img000,0150,120,150,120);
    
header("Content-type: image/jpeg");
    
imagejpeg($thumb);
}
?>