Foros del Web » Programando para Internet » PHP »

Problemas con GD al mostrar una imagen dentro de otra.

Estas en el tema de Problemas con GD al mostrar una imagen dentro de otra. en el foro de PHP en Foros del Web. Hola! Resulta ser que estoy intentando hacer una firma dinamica para un foro. He encontrado un codigo de hacer thumbnails y el thumbnail generado quiero ...
  #1 (permalink)  
Antiguo 27/11/2007, 16:13
Avatar de thesixhalcon  
Fecha de Ingreso: noviembre-2007
Ubicación: Madrid (España)
Mensajes: 55
Antigüedad: 16 años, 5 meses
Puntos: 1
Problemas con GD al mostrar una imagen dentro de otra.

Hola!

Resulta ser que estoy intentando hacer una firma dinamica para un foro. He encontrado un codigo de hacer thumbnails y el thumbnail generado quiero mostrarlo sobre otra imagen tambien generada.

Sería asi como lo tengo ahora:
Código PHP:
<?php
header
("Content-type: image/png"); //El tipo de imágen
$im "firma.png"//Url COMPLETA de la imágen
$img ImageCreateFromPng($im);
$color ImageColorAllocate($img2551530); 
$color_shadow2 ImageColorAllocate($img888888);
$color_shadow  ImageColorAllocate($img363636); 
$color_link    ImageColorAllocate($img142142142); 

$texto .= "Usuario:                                                  Últ.Archivo:
Posts:                                                       Modelo SE:
Gracias:
"

$col1  "The Sixth Halcon
217
82
"
;
$col2 "Firmware_w580(i)_s...
w580i
"
;

$link     "http://www.SE-Planet.com";

ImageTTFText($img10010163$color_shadow"./calibri.ttf",$texto);
ImageTTFText($img10010062$color"./calibri.ttf",$texto);
    
ImageTTFText($img10015663$color_shadow"./calibri.ttf",$col1);
ImageTTFText($img10015562$color"./calibri.ttf",$col1);
    
ImageTTFText($img10037163$color_shadow"./calibri.ttf",$col2);
ImageTTFText($img10037062$color"./calibri.ttf",$col2);

ImageTTFText($img100355120$color_link"./calibri.ttf",$link);
/*
Pequeña explicación de esta función:
Estructura: array imagettftext ( resource imagen, int tamanyo, int angulo, int x, int y, int color, string archivo_fuente, string texto)

* El primer "0" se corresponde a la coordenada X en el cual posicionar el "logotipo" y el segundo "0" la coordenada Y.
* El tercero se refiere a la coordenada X desde la cual empezar a copiar el "logotipo" por lo general siempre será 0 en caso de que quieras hacer algo así como un "recorte" el cuarto "0" se refiere a la coordenada Y.
* Y estos 2 últimos valores se refiere a la anchura y altura en píxeles del recorte. Por lo tanto si quieres copiar el "logotipo" completo, deberías dejar el tercero y cuarto "0" como "0" y estos 2 últimos valores con las dimensiones del "logotipo".

*/
function thumbnail$URL$outWidth$outHeight) {
    
    
$ext explode("."$URL);
    
$count count($ext);
    
$count $count-1;
    
    
//Do it
    
if($ext[$count] == "jpg"){ $imgSrc=imagecreatefromjpeg($URL); }
    if(
$ext[$count] == "gif"){ $imgSrc=imagecreatefromgif($URL);  }
    if(
$ext[$count] == "png"){ $imgSrc=imagecreatefrompng($URL);  }
    if(
$ext[$count] == "bmp"){ $imgSrc=imagecreatefromwbmp($URL); }
    
    
$srcWidth=imagesx($imgSrc);
    
$srcHeight=imagesy($imgSrc);
    
    
//Make thumbnails
    
$imgOut=imagecreatetruecolor($outWidth,$outHeight);
    
imagerectangle($imgOut,0,0,$outWidth,$outHeight,imagecolorallocate($imgOut,0,0,0));
    
    
//Copy them proportionatly
    
$dx=0$dy=0$dw=$outWidth$dh=$outHeight;
    if (
$outWidth*$srcHeight!=$outHeight*$srcWidth) { //Non-proportional, cut-off
     //Which dimensions is larger
     
if ($srcWidth>$srcHeight) { //Empty space on top and bottom
      
$dw=$outWidth;
      
$dh=($dw*$srcHeight)/$srcWidth;
      
$dy=($outHeight-$dh)/2;
     }
     else { 
//Empty space on left and right
      
$dh=$outHeight;
      
$dw=($dh*$srcWidth)/$srcHeight;
      
$dx=($outWidth-$dw)/2;
     }
    }
    
    
imagecopyresampled($imgOut,$imgSrc,$dx,$dy,0,0,$dw,$dh,$srcWidth,$srcHeight); //imagecopyresized for lower quality
    
    //Create the thumbnail and destroy everything else
    
imagepng($imgOut);
    
imagedestroy($imgSrc);
    
imagedestroy($imgOut);
}
//thumbnail($_GET['URL'], 68, 68);

imagecopy($imgimagecreatefrompng('http://seking.es/Firma/foto.png'), 1747007070);
imagecopy($imgthumbnail($_GET['URL'], 6868), 1848006868);
ImagePng($img); 
ImageDestroy($img); 
?>
El problema es cuando pongo "thumbnail($_GET['URL'], 68, 68)" envía la imagen del thumbnail, pero no la mete dentro del supuesto cuadro. Para que lo veais mejor, aqui os dejo un GD que hice antes para estructurar todo:
http://s222200603.mialojamiento.es/Firma/

Y aqui os dejo el generador de thumbnails, que es otro archivo que contiene "function thumbnail( $URL, $outWidth, $outHeight)"
http://s222200603.mialojamiento.es/Firma/gt.php?URL=http://img218.imageshack.us/img218/428/indexphpzv0.gif&W=100&H=100

A ver si me podeis ayudar a que muestre lo que se quiere mostrar....

Gracias de antemano!!!!
  #2 (permalink)  
Antiguo 28/11/2007, 10:39
Avatar de thesixhalcon  
Fecha de Ingreso: noviembre-2007
Ubicación: Madrid (España)
Mensajes: 55
Antigüedad: 16 años, 5 meses
Puntos: 1
Re: Problemas con GD al mostrar una imagen dentro de otra.

Ya lo solucioné! ;) imagecopyresized();

Gracias de todos modos!

Última edición por thesixhalcon; 28/11/2007 a las 13:00
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 19:26.