I have a script that should write text into a rectangle that is generated by php. Here is what I really get with the below script.
Image and the image I used to create it with First Image and below is the code that I used, but as you can see the first link that resulted from the script has nothing in the little rectangle produced by the script.
$font = realpath("cour.ttf") ;
$text ="Test text to image";
$sizes = imagettfbbox ( 8, 0, $font, $text) ;
// Set the content-type
//header("Content-type: image/png");
//So replace by default smiley
if ($smileyimage == "")
{
$smileyimage = imagecreatefrompng ("smiley_normal.png") ;
//Get size of default smiley
$addy = getImageSize ("smiley_normal.png") ;
}
else
{
//Get size of smiley
$addy = getImageSize ("smiley_normal.png") ;
}
//Minimumsize of Image for Smiley
$w = max ($addy[0], $sizes[2]) ;
//Create image
$mainimage = imagecreate($w+10, $addy[1]+30);
// allocate Colors
$white = imagecolorallocate ($mainimage, 255, 255, 255) ;
$black = imagecolorallocate ($mainimage, 0, 0, 0) ;
$bg = imagecolorallocate ($mainimage, 255, 0, 255) ;
//set wannabe-transparancy-color to background
imagefill ($mainimage, 0, 0, $bg) ;
//copy smiley into image
imagecopyresized($mainimage, $smileyimage, (($w+10)-$addy[0]) / 2, 30, 0, 0, $addy[0], $addy[1], $addy[0], $addy[1]) ;
//draw poster
imagerectangle ($mainimage, 0, 0, $w+9, 29, $black) ;
imagefilledrectangle ($mainimage, 1, 1, $w+8, 28, $white) ;
//draw text
imagettftext ($mainimage, 8, 0, ( $w - $sizes[2]+10)/2, 24, $green, $font, $text) ;
//do the rest *g*
imagecolortransparent($mainimage, $bg) ;
//header("Content-Type: image/png");
imagepng ($mainimage) ;
imagedestroy($mainimage);
What do I need to correct ths script and actually get a message in the rectangle (sign)?
Here is the JavaScript that is supposed to get the text variable
$gen_simple_header = 1;
$page_title = $lang['Smilie_creator'];
// include($phpbb_root_path . 'includes/page_header.'.$phpEx);
$smileydir = opendir ("./smileygenerator") ;
$i == 0 ;
?>
<script language="javascript" type="text/javascript">
<!--
function emoticon(text) {
text = '[smiley poster=' + text + ']' + document.forms['eingabeform'].eingabe.value + '[/smiley] ';
if (opener.document.forms['post'].message.createTextRange && opener.document.forms['post'].message.caretPos) {
var caretPos = opener.document.forms['post'].message.caretPos;
caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
opener.document.forms['post'].message.focus();
} else {
opener.document.forms['post'].message.value += text;
opener.document.forms['post'].message.focus();
window.close() ;
}
}
//-->
</script>
<center><table border=0 class="forumline">
<tr>
<th class="thHead">
<table border=0 width="100%">
<tr>
<td><center><b><font>Bild</font></b></center></td>
<td><center><b>Key</b></center></td>
<td><center><b>Bild</b></center></td>
<td><center><b>Key</b></center></td>
</tr>
</table>
</th>
</tr><tr>
<td class="row1">
<table border=0>
<tr>
<?
while ($file = readdir ($smileydir))
{
if ($file != "." && $file != "..")
{
if (preg_match ("/smiley\_(.+)\.png/i", $file))
{
$key = preg_replace ("/smiley\_(.+)\.png/i", "\\1", $file) ;
echo "<td><center><a href=\"javascript: emoticon ('$key')\"><img src=\"./smileygenerator/smileygenerator.php?smiley=$key&text=\" border=0></a></center></td>" ;
echo "<td><center>"$key"</center></td>" ;
if ($i % 2 == 1)
echo "</tr><tr>" ;
$i++ ;
}
}
}
if ($i % 2 == 1)
{
echo "<td> </td>" ;
echo "<td> </td>" ;
}
?>
</tr>
<tr>
<td colspan=2>Text:</td>
<td colspan=2><form name="eingabeform">
<input type="text" name="eingabe" size=14>
</form></td>
</tr>
</table>
</td>
</tr>
<tr>
<td class="catBottom"><center><b><a href="javascript:window.close()">Schliessen</a></b></center></td>
</tr>
</table></center>
</body>
</html>
I do not speack German but Schliessen means xomething like close Window of close.