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($img, 255, 153, 0);
$color_shadow2 = ImageColorAllocate($img, 88, 88, 88);
$color_shadow = ImageColorAllocate($img, 36, 36, 36);
$color_link = ImageColorAllocate($img, 142, 142, 142);
$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($img, 10, 0, 101, 63, $color_shadow, "./calibri.ttf",$texto);
ImageTTFText($img, 10, 0, 100, 62, $color, "./calibri.ttf",$texto);
ImageTTFText($img, 10, 0, 156, 63, $color_shadow, "./calibri.ttf",$col1);
ImageTTFText($img, 10, 0, 155, 62, $color, "./calibri.ttf",$col1);
ImageTTFText($img, 10, 0, 371, 63, $color_shadow, "./calibri.ttf",$col2);
ImageTTFText($img, 10, 0, 370, 62, $color, "./calibri.ttf",$col2);
ImageTTFText($img, 10, 0, 355, 120, $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($img, imagecreatefrompng('http://seking.es/Firma/foto.png'), 17, 47, 0, 0, 70, 70);
imagecopy($img, thumbnail($_GET['URL'], 68, 68), 18, 48, 0, 0, 68, 68);
ImagePng($img);
ImageDestroy($img);
?>
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!!!!