Foros del Web » Programando para Internet » PHP »

Problema imagenes Libreria GD

Estas en el tema de Problema imagenes Libreria GD en el foro de PHP en Foros del Web. Bueno tengo un host de imagenes y al subirlas en PNG(con fondo transparente) o GIF(con movimiento) a las PNG le pone fondo blanco y a ...
  #1 (permalink)  
Antiguo 10/08/2010, 07:11
 
Fecha de Ingreso: octubre-2009
Mensajes: 41
Antigüedad: 14 años, 6 meses
Puntos: 0
Problema imagenes Libreria GD

Bueno tengo un host de imagenes y al subirlas en PNG(con fondo transparente) o GIF(con movimiento) a las PNG le pone fondo blanco y a las gif se quedan estaticas. Investigando me dijeron que el problema estaba en las librerias GD, busque y encontre este codigo.. queria saber si alguien me diria cual es el error por lo que ocurre lo anteriormente mencionado Muchas Gracias

Código PHP:
<?php

require_once("../inc/config.php" ) ;
require_once(
"../inc/func.php" ) ;

// Path to the the requested file
$string "_tn.";
$referer $_SERVER['HTTP_REFERER'];
$ip $_SERVER['REMOTE_ADDR'];
$defaultImage "default.gif";
$path $_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'];
$path_parts pathinfo($path) ;
$file_ext strtolower($path_parts['extension']) ;

if (
$file_ext == "bmp" ) {

$image ImageCreateFromBMP(file_get_contents($path)) ;

} else {
// Load the requested image
$image imagecreatefromstring(file_get_contents($path)) ;
}
$w imagesx($image) ;
$h imagesy($image) ;


if(
$watermarking=="1" ) {

if(
$w<"300" || $h<"300" ) {
$watermark imagecreatefrompng('th_watermark.png') ;
}

else {
// Load the watermark image
$watermark imagecreatefrompng('watermark.png') ;
}
$ww imagesx($watermark) ;
$wh imagesy($watermark) ;

// Merge watermark upon the original image
imagecopy($image$watermark$w-$ww$h-$wh00$ww$wh) ;

// Send the image

if ($file_ext == "bmp" ) {
header('Content-type: image/bmp') ;
imagebmp($image,$file="",$RLE=0) ;
imagedestroy($image) ;
exit() ; }
if (
$file_ext == "png" ) {
header('Content-type: image/png') ;
imagepng($image) ;
imagedestroy($image) ;
exit() ; }
if (
$file_ext == "gif" ) {
header('Content-type: image/gif') ;
imagegif($image) ;
imagedestroy($image) ;
exit() ; }

if (
$file_ext == "jpg" ) {
header('Content-type: image/jpeg') ;
imagejpeg($image) ;
imagedestroy($image) ;
exit() ;}
if (
$file_ext == "jpeg" ) {
header('Content-type: image/jpeg') ;
imagejpeg($image) ;
imagedestroy($image) ;
exit() ;}

}

// don't watermark if watermarking is disabled
if($watermarking=="0" ) {
if (
$file_ext == "bmp" ) {
header('Content-type: image/bmp') ;
imagebmp($image,$file="",$RLE=0) ;
imagedestroy($image) ;
exit() ; }
if (
$file_ext == "png" ) {
header('Content-type: image/png') ;
imagepng($image) ;
imagedestroy($image) ;
exit() ; }
if (
$file_ext == "gif" ) {
header('Content-type: image/gif') ;
imagegif($image) ;
imagedestroy($image) ;
exit() ; }
if (
$file_ext == "jpg" ) {
header('Content-type: image/jpeg') ;
imagejpeg($image) ;
imagedestroy($image) ;
exit() ;
}
if (
$file_ext == "jpeg" ) {
header('Content-type: image/jpeg') ;
imagejpeg($image) ;
imagedestroy($image) ;
exit() ;}

}
?>
  #2 (permalink)  
Antiguo 15/08/2010, 17:13
 
Fecha de Ingreso: junio-2007
Ubicación: Buenos Aires, Argentina
Mensajes: 262
Antigüedad: 16 años, 10 meses
Puntos: 1
Respuesta: Problema imagenes Libreria GD

Me temo que no puedo ayudarte con la parte de las animaciones, pero respecto a la transparencia de los PNG y GIFs, no veo una parte del código que haga eso. Para hacerlo, el código es algo así:

Código PHP:
Ver original
  1. $transparente = imagecolorallocate($img, 255, 255, 255);
  2. imagefill($img, 0, 0, $transparente);
  3. imagecolortransparent($img, $transparente);
__________________
Moebius Digital | La pieza que faltaba
Diseño web | Web hosting

Etiquetas: imagenes, libreria
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 20:41.