Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Derme

[Resolvido] Gif transparente (gif 89)

Recommended Posts

Olá!

Estou com esse código que gera imagens em tempo real e

necessito que aceite gif com fundo transparente, porém

quando chamo uma gif com fundo transparente (gif 89)

tudo que consigo é que a área transparente fique cinza!!

alguém sabe como corrigir?

 

 

$forcedwidth="200";// $_GET['larg_mini'];
$forcedheight="200";// $_GET['alt_mini'];
$sourcefile= "transparente.gif";//$_GET['imagem'];

$imgcomp=50;

   $g_imgcomp=100-$imgcomp;
   $g_srcfile=$sourcefile;
   $g_dstfile=$destfile;
   $g_fw=$forcedwidth;
   $g_fh=$forcedheight;
	
	//======= BUSCANDO EXTENSÕES =======================				
	ereg('\.([^\.]*$)', $g_srcfile, $extencao1);
   if (is_array($extencao1)) {
	  $extencao2 = strtolower($extencao1[1]);	
	   $extn = $extencao2;
	}																		 
	//======= FIM BUSCANDO EXTENSÕES ===================	

   if(file_exists($g_srcfile)) {
	   $g_is = getimagesize($g_srcfile);
	   if(($g_is[0]-$g_fw)>=($g_is[1]-$g_fh))
		   {
		   $g_iw=$g_fw;
		   $g_ih=($g_fw/$g_is[0])*$g_is[1];//$g_iw;
		   }
		   else
		   {
		   $g_ih=$g_fh;
		   $g_iw=($g_ih/$g_is[1])*$g_is[0];//$g_ih;   
		   }
			  
		//|| DETERMINANDO TIPO DE ARQUIVO |||
		if($extn=='jpg'|| $extn == 'jpeg'){ 
		   $img_src=imagecreatefromjpeg($g_srcfile); 
		}elseif($extn=='png'){ 
		   $img_src=imagecreatefrompng($g_srcfile); 
		}elseif($extn=='gif'){ 			   
		   $img_src=imagecreatefromgif($g_srcfile);
		}else{
		   $img_src=imagecreatefromjpeg($g_srcfile);
		}										  
		//|| FIM DETERMINANDO TIPO DE ARQUIVO ||
		
	  if($extn=='gif'){
		   $img_dst=imagecreate($g_iw,$g_ih);
		}else{
		$img_dst=imagecreatetruecolor($g_iw,$g_ih);		
	   }
		
	  imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $g_iw, $g_ih, $g_is[0], $g_is[1]);
	  
		//|| DETERMINANDO TIPO DE ARQUIVO |||
		if($extn=='jpg'|| $extn == 'jpeg'){ 
		   header( "Content-type:  image/JPEG");
		 imagejpeg($img_dst);
		 imagedestroy($img_dst); 
		}elseif($extn=='png'){ 
		   header( "Content-type:  image/PNG");
		 imagepng($img_dst);
		 imagedestroy($img_dst); 
		}elseif($extn=='gif'){ 				
		   header( "Content-type:  image/GIF");					
		 imagegif($img_dst);			
			imagedestroy($img_dst);
		}else{
		   header( "Content-type:  image/JPEG");
			imagejpeg($img_dst);
		 imagedestroy($img_dst); 
		}										  
		//|| FIM DETERMINANDO TIPO DE ARQUIVO ||
	   
		 
	}

Compartilhar este post


Link para o post
Compartilhar em outros sites

Resolvido!

include "register_globals.php";
$forcedwidth="200";// $_GET['larg_mini'];
$forcedheight="200";// $_GET['alt_mini'];
$sourcefile= "logo2.gif";//$_GET['imagem'];

$imgcomp=50;

   $g_imgcomp=100-$imgcomp;
   $g_srcfile=$sourcefile;
   $g_dstfile=$destfile;
   $g_fw=$forcedwidth;
   $g_fh=$forcedheight;
	
	//======= BUSCANDO EXTENSÕES =======================				
	ereg('\.([^\.]*$)', $g_srcfile, $extencao1);
   if (is_array($extencao1)) {
	  $extencao2 = strtolower($extencao1[1]);	
	   $extn = $extencao2;
	}																		 
	//======= FIM BUSCANDO EXTENSÕES ===================	

   if(file_exists($g_srcfile)) {
	   $g_is = getimagesize($g_srcfile);
	   if(($g_is[0]-$g_fw)>=($g_is[1]-$g_fh))
		   {
		   $g_iw=$g_fw;
		   $g_ih=($g_fw/$g_is[0])*$g_is[1];//$g_iw;
		   }
		   else
		   {
		   $g_ih=$g_fh;
		   $g_iw=($g_ih/$g_is[1])*$g_is[0];//$g_ih;   
		   }
			  
		//|| DETERMINANDO TIPO DE ARQUIVO |||
		if($extn=='jpg'|| $extn == 'jpeg'){ 
		   $img_src=imagecreatefromjpeg($g_srcfile); 
		}elseif($extn=='png'){ 
		   $img_src=imagecreatefrompng($g_srcfile); 
		}elseif($extn=='gif'){ 			   
		   $img_src=imagecreatefromgif($g_srcfile);						 
		}else{
		   $img_src=imagecreatefromjpeg($g_srcfile);
		}										  
		//|| FIM DETERMINANDO TIPO DE ARQUIVO ||
		
	  if($extn=='gif'){
		   $img_dst=imagecreate($g_iw,$g_ih);			 
			$cor_trans=imagecolorallocatealpha($img_dst, 0,0,0,127);
			imagecolortransparent ($img_dst,$cor_trans); 		   
		}else{
		$img_dst=imagecreatetruecolor($g_iw,$g_ih);		
	   }		
	  imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $g_iw, $g_ih, $g_is[0], $g_is[1]);
	  
		//|| DETERMINANDO TIPO DE ARQUIVO |||
		if($extn=='jpg'|| $extn == 'jpeg'){ 
		   header( "Content-type:  image/JPEG");
		 imagejpeg($img_dst);
		 imagedestroy($img_dst); 
		}elseif($extn=='png'){ 
		   header( "Content-type:  image/PNG");
		 imagepng($img_dst);
		 imagedestroy($img_dst); 
		}elseif($extn=='gif'){ 				
		   header( "Content-type:  image/GIF");					
		 imagegif($img_dst);			
			imagedestroy($img_dst);
		}else{
		   header( "Content-type:  image/JPEG");
			imagejpeg($img_dst);
		 imagedestroy($img_dst); 
		}										  
		//|| FIM DETERMINANDO TIPO DE ARQUIVO ||
	   
		 
	}

Compartilhar este post


Link para o post
Compartilhar em outros sites

Resolvido!

include "register_globals.php";
$forcedwidth="200";// $_GET['larg_mini'];
$forcedheight="200";// $_GET['alt_mini'];
$sourcefile= "logo2.gif";//$_GET['imagem'];

$imgcomp=50;

   $g_imgcomp=100-$imgcomp;
   $g_srcfile=$sourcefile;
   $g_dstfile=$destfile;
   $g_fw=$forcedwidth;
   $g_fh=$forcedheight;
	
	//======= BUSCANDO EXTENSÕES =======================				
	ereg('\.([^\.]*$)', $g_srcfile, $extencao1);
   if (is_array($extencao1)) {
	  $extencao2 = strtolower($extencao1[1]);	
	   $extn = $extencao2;
	}																		 
	//======= FIM BUSCANDO EXTENSÕES ===================	

   if(file_exists($g_srcfile)) {
	   $g_is = getimagesize($g_srcfile);
	   if(($g_is[0]-$g_fw)>=($g_is[1]-$g_fh))
		   {
		   $g_iw=$g_fw;
		   $g_ih=($g_fw/$g_is[0])*$g_is[1];//$g_iw;
		   }
		   else
		   {
		   $g_ih=$g_fh;
		   $g_iw=($g_ih/$g_is[1])*$g_is[0];//$g_ih;   
		   }
			  
		//|| DETERMINANDO TIPO DE ARQUIVO |||
		if($extn=='jpg'|| $extn == 'jpeg'){ 
		   $img_src=imagecreatefromjpeg($g_srcfile); 
		}elseif($extn=='png'){ 
		   $img_src=imagecreatefrompng($g_srcfile); 
		}elseif($extn=='gif'){ 			   
		   $img_src=imagecreatefromgif($g_srcfile);						 
		}else{
		   $img_src=imagecreatefromjpeg($g_srcfile);
		}										  
		//|| FIM DETERMINANDO TIPO DE ARQUIVO ||
		
	  if($extn=='gif'){
		   $img_dst=imagecreate($g_iw,$g_ih);			 
			$cor_trans=imagecolorallocatealpha($img_dst, 0,0,0,127);
			imagecolortransparent ($img_dst,$cor_trans); 		   
		}else{
		$img_dst=imagecreatetruecolor($g_iw,$g_ih);		
	   }		
	  imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $g_iw, $g_ih, $g_is[0], $g_is[1]);
	  
		//|| DETERMINANDO TIPO DE ARQUIVO |||
		if($extn=='jpg'|| $extn == 'jpeg'){ 
		   header( "Content-type:  image/JPEG");
		 imagejpeg($img_dst);
		 imagedestroy($img_dst); 
		}elseif($extn=='png'){ 
		   header( "Content-type:  image/PNG");
		 imagepng($img_dst);
		 imagedestroy($img_dst); 
		}elseif($extn=='gif'){ 				
		   header( "Content-type:  image/GIF");					
		 imagegif($img_dst);			
			imagedestroy($img_dst);
		}else{
		   header( "Content-type:  image/JPEG");
			imagejpeg($img_dst);
		 imagedestroy($img_dst); 
		}										  
		//|| FIM DETERMINANDO TIPO DE ARQUIVO ||
	   
		 
	}

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.