rendered paste body<?php header("Content-type: image/png"); # http://de2.php.net/manual/de/function.imagettftext.php#76871# original by: Taslim Mazumder Sohel# modified by: ( -: roland :- )//Example call.$str = str_replace("_"," ",@$_GET['str']);$str = $str."\n".$str."\n".$str."\n";//"Zeile 1\nZeile 2\nZeile 3\n"; $pos = (@$_GET['pos']) ? @$_GET['pos'] : 0;$fsize = (@$_GET['fsize']) ? @$_GET['fsize'] : 12;imagepng(imagettfJustifytext($str,$pos,"fonts/cooper.ttf",$fsize));//if (@$_GET['id'] && !file_exists('menu/'.@$_GET['id'].'.png')) imagepng(imagettfJustifytext($str,$pos,"fonts/cooper.ttf",$fsize), 'menu/'.@$_GET['id'].'.png'); //End of example.# @name : makeImageF# Function for create image from text with selected font. # Justify text in image (0-Left, 1-Right, 2-Center).# @param String $text : String to convert into the Image.# @param String $font : Font name of the text. Kip font file in same folder.# @param int $W : Width of the Image.# @param int $H : Hight of the Image.# @param int $X : x-coordinate of the text into the image.# @param int $Y : y-coordinate of the text into the image.# @param int $fsize : Font size of text.function imagettfJustifytext($text, $Justify=0, $font="fonts/cooper.ttf", $fsize=12, $W=120, $H=60, $X=0, $Y=0) {//Defining the Colors (background,normal,hover,active) $tc=array( array(0xdd,0xdd,0xdd), array(0x00,0x00,0x00), array(0xff,0x00,0x00), array(0xff,0xff,0x00)); $angle = 0; $L_R_C = $Justify; $_bx = imageTTFBbox($fsize,0,$font,$text); $W = 120;//($W==0) ? abs($_bx[2]-$_bx[0]) : $W; $H = 60;//($H==0) ? abs($_bx[5]-$_bx[3]) : $H; $im = @imagecreate($W, $H) or die("Cannot Initialize new GD image stream"); $nr = 0; $background_color = imagecolorallocate($im, $tc[$nr][0], $tc[$nr][1], $tc[$nr][2]); if ($L_R_C == 0) { //Justify Left $s = split("[\n]+", $text); $__H = 0;//$fsize/2; foreach($s as $key => $val) { $nr++; $text_color = imagecolorallocate($im, $tc[$nr][0], $tc[$nr][1], $tc[$nr][2]); $_b = imageTTFBbox($fsize,0,$font,$val); $_W = abs($_b[2]-$_b[0]);//Defining the X coordinate. $_X = 0;//abs($W/2)-abs($_W/2);//Defining the Y coordinate. $_H = abs($_b[5]-$_b[3]); $__H += 20;//$_H; imagettftext($im, $fsize, $angle, $X, $__H, $text_color, $font, $val); // $__H += $fsize/2; } } elseif ($L_R_C == 1) { //Justify Right $s = split("[\n]+", $text); $__H = 0;//$fsize/2;//0; foreach($s as $key => $val){$nr++; $text_color = imagecolorallocate($im, $tc[$nr][0], $tc[$nr][1], $tc[$nr][2]); $_b = imageTTFBbox($fsize,0,$font,$val); $_W = abs($_b[2]-$_b[0]);//Defining the X coordinate. $_X = $W-$_W-12;//Defining the Y coordinate.// $_H = abs($_b[5]-$_b[3]); $__H += 20;//$_H; imagettftext($im, $fsize, $angle, $_X, $__H, $text_color, $font, $val); // $__H += $fsize/2; } } elseif($L_R_C == 2){ //Justify Center $s = split("[\n]+", $text); $__H = 0;//$fsize/2;//0; foreach($s as $key => $val) { $nr++; $text_color = imagecolorallocate($im, $tc[$nr][0], $tc[$nr][1], $tc[$nr][2]); $_b = imageTTFBbox($fsize,0,$font,$val); $_W = abs($_b[2]-$_b[0]);//Defining the X coordinate. $_X = abs($W/2)-abs($_W/2)-12;//Defining the Y coordinate. $_H = abs($_b[5]-$_b[3]); $__H += 20;//$_H; imagettftext($im, $fsize, $angle, $_X, $__H, $text_color, $font, $val); // $__H += $fsize/2; } } return $im;}?>