All pastes #131686 Raw Edit

Anonymous

public text v1 · immutable
#131686 ·published 2006-08-14 16:35 UTC
rendered paste body
<?PHP

include('allfiles.inc.php'); 

 

$font = empty($_GET['font']) ? './fontdata/baveuse.ttf' : $_GET['font'];
$filename = ($_GET['font']).".png";
$size = empty($_GET['size']) ? '20' : $_GET['size'];
$text = empty($_GET['text']) ? "WriteToDesign" : $_GET['text'];
$color = empty($_GET['color']) ? "000000" : $_GET['color'];
$bcolor = empty($_GET['bcolor']) ? "FFFFFF" : $_GET['bcolor'];

$data = array('font' => $font, 'size' => $size, 'text' => $text, 'color' => $color, 'bcolor' => $bcolor);

$sum = md5(serialize($data));
$filename = $sum.'.png';


$Image_Width=600;
$Image_Height=85;

// Create the image
$im = imagecreatetruecolor ($Image_Width, $Image_Height);


{

	$wh = imagecolorallocate($im, hexdec(substr($bcolor, 0, 2)), hexdec(substr($bcolor, 2, 2)), hexdec(substr($bcolor, 4, 2)));
	$bl = imagecolorallocate($im, hexdec(substr($color, 0, 2)), hexdec(substr($color, 2, 2)), hexdec(substr($color, 4, 2)));
	imagefill($im,0,0,$wh); 


	// $text = gentext(); 
$Text_Box_Size = imagettfbbox($size, 0, $font, $text);
   $Text_Box_Width = abs($Text_Box_Size[2] + $Text_Box_Size[0]);
   $Text_Box_Height = abs($Text_Box_Size[7] + $Text_Box_Size[1]);
   $Text_Height = $Text_Height + $Text_Box_Height;
   $posx = ($Image_Width - $Text_Box_Width) / 2;
   $posy = ($Image_Height - $Text_Box_Height * sizeof($text)) / 2 + $Text_Height;


   
imagettftext($im, $size, 0, $posx, $posy, $bl, $font, $text);

	// imagettftext($im,10,0,10,91,$bl,$font,$sum); 

	header("Content-type: image/png");

	imagepng($im,$filename);
}

imagepng($im);
imagedestroy($im);

function gentext() {
	$text='';
	for ($i=28; $i<256; $i++)
		$text .= chr($i);
	return $text; 
}