Foros del Web » Programando para Internet » PHP »

No me resamplea PNG

Estas en el tema de No me resamplea PNG en el foro de PHP en Foros del Web. Código PHP:      function  Parse ( $File )     {         if(! is_dir ( $this -> _To . '[' . $this -> Max [ 'Setted' ]. ']' ...
  #1 (permalink)  
Antiguo 17/05/2009, 18:45
Avatar de Fernand0  
Fecha de Ingreso: septiembre-2005
Ubicación: Buenos Aires
Mensajes: 610
Antigüedad: 18 años, 7 meses
Puntos: 19
No me resamplea PNG

Código PHP:
    function Parse($File)
    {
        if(!
is_dir($this->_To.'['.$this->Max['Setted'].']')) mkdir($this->_To.'['.$this->Max['Setted'].']');
        
        
$Type=substr($File, -3);
        
        if(
$Type=='jpg' || $Type=='peg') { $this->Img=imagecreatefromjpeg($this->From.'/'.$File); }
        else if(
$Type=='png') { $this->Img=imagecreatefrompng($this->From.'/'.$File); }
        else if(
$Type=='gif') { $this->Img=imagecreatefromgif($this->From.'/'.$File); }
        else if(
$Type=='bmp') { $this->Img=imagecreatefromwbmp($this->From.'/'.$File); }
        
        
$this->Calc();
        
$Created=imagecreatetruecolor($this->w$this->h);
        
imagecopyresampled($Created$this->Img0000$this->w$this->h$this->Max['w'], $this->Max['h']);
        
        if(
$Type=='jpg' || $Type=='peg') { imagejpeg($Created$this->_To.'['.$this->Max['Setted'].']/'.$File100); }
        else if(
$Type=='png') { imagepng($Created$this->_To.'['.$this->Max['Setted'].']/'.$File); }
        else if(
$Type=='gif') { imagegif($Created$this->_To.'['.$this->Max['Setted'].']/'.$File); }
        else if(
$Type=='bmp') { imagewbmp($Created$this->_To.'['.$this->Max['Setted'].']/'.$File); }
        
        
imagedestroy($Created); imagedestroy($this->Img);
    } 
Por alguna razon, funciona solo con .jpg(esto indica que el resto del codigo esta bien)
Cual es el problema? :S

Saludos
  #2 (permalink)  
Antiguo 17/05/2009, 20:10
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: No me resamplea PNG

¿Que error te muestra? ¿haz comprobado que $Type sea == 'png'?.

Saludos.
  #3 (permalink)  
Antiguo 17/05/2009, 20:22
Avatar de Fernand0  
Fecha de Ingreso: septiembre-2005
Ubicación: Buenos Aires
Mensajes: 610
Antigüedad: 18 años, 7 meses
Puntos: 19
Respuesta: No me resamplea PNG

Si, es png, de hecho si solo dejo el imagepng sin if funciona exactamente igual, pero el problema es que la imagen queda resampleada en negro, se ve todo negro :S

o sea si lo dejo asi.. funciona exactamente igual

Código PHP:
imagecopyresampled($Created$this->Img0000$this->w$this->h$this->Max['w'], $this->Max['h']);
        
        
imagepng($Created$this->_To.'['.$this->Max['Setted'].']/'.$File);
        
        
imagedestroy($Created); imagedestroy($this->Img); 
Error.. ninguno :s

Saludos
  #4 (permalink)  
Antiguo 17/05/2009, 20:25
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 11 meses
Puntos: 2135
Respuesta: No me resamplea PNG

Verifica que tu PNG no tenga canales Alpha, en cuyo caso usa imagetransparent para establecer el color del canal alpha, o imagealphablending junto con imagesavealpha.

Saludos.
  #5 (permalink)  
Antiguo 17/05/2009, 22:10
Avatar de Fernand0  
Fecha de Ingreso: septiembre-2005
Ubicación: Buenos Aires
Mensajes: 610
Antigüedad: 18 años, 7 meses
Puntos: 19
Respuesta: No me resamplea PNG

Bueno..

Despues de estar como un idiota durante 2hrs probando y probando, busque algunas .png que tenia escondidas por ahi y resamplearon perfectamente incluso con el alpha :S

Al parecer... por una loca razon, no se pueden resamplear imagenes guardadas DESDE PAINT con otro formato.... incognita total...

Busque a ver, si habia algun problema, una posible solucion, nada... no encontre nada... :S

Gracias GatorV y perdon por hacerte perder el tiempo -_-
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 18:14.