Ver Mensaje Individual
  #16 (permalink)  
Antiguo 05/07/2011, 12:58
Avatar de iviamontes
iviamontes
 
Fecha de Ingreso: enero-2011
Ubicación: $cubano->Arg->Mendoza
Mensajes: 1.184
Antigüedad: 15 años, 8 meses
Puntos: 209
Respuesta: [APORTE] Subir y redimensionar imagenes

por si le sirve a alguien, la clase analizada acá, cuando hace el cambio de tamaño de un gif con transparencia, este la pierde y en su lugar aparece el típico fondo negro, al método resize el hice un cambio que soluciona esto.

Código PHP:
  public function resize($width, $height)
  {
        
$newImage = imagecreatetruecolor($width, $height);
    if(
$this->getImageType() == 'image/png' && $this->_transparent === true)
     {
      
imagealphablending($newImage, false);
      
imagesavealpha($newImage, true);
      
$transparent = imagecolorallocatealpha($newImage, 255, 255, 255, 127);
      
imagefilledrectangle($newImage, 0, 0, $width, $height, $transparent);
      
imagecopyresampled($newImage, $this->_image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
         }
      else if(
$this->getImageType() == 'image/gif' && $this->_transparent === true)
        {
            
$transcolor=imagecolortransparent($this->_image);
            if(
$transcolor!=-1)
            {
                 
$trnprt_color = imagecolorsforindex($this->_image, $transcolor);
                 
$trnprt_indx = imagecolorallocatealpha($newImage, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue'], $trnprt_color['alpha']);
                 
imagefill($newImage, 0, 0, $trnprt_indx);
                 
imagecolortransparent($newImage, $trnprt_indx);                 
            }
            
imagecopyresized($newImage, $this->_image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());  
        }
        else
      
imagecopyresampled($newImage, $this->_image, 0, 0, 0, 0, $width, $height, $this->getWidth(), $this->getHeight());
         
$this->_image = $newImage;
  } 
espero le sirva a alguien
__________________
aconcaguaestudio.com