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: 13 años, 3 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($newImagefalse);
      
imagesavealpha($newImagetrue);
      
$transparent imagecolorallocatealpha($newImage255255255127);
      
imagefilledrectangle($newImage00$width$height$transparent);
      
imagecopyresampled($newImage$this->_image0000$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($newImage00$trnprt_indx);
                 
imagecolortransparent($newImage$trnprt_indx);                 
            }
            
imagecopyresized($newImage$this->_image0000$width$height$this->getWidth(), $this->getHeight());  
        }
        else
      
imagecopyresampled($newImage$this->_image0000$width$height$this->getWidth(), $this->getHeight());
         
$this->_image $newImage;
  } 
espero le sirva a alguien
__________________
aconcaguaestudio.com