<?php
//http://www.eksperten.dk/spm/804242
//Funktion fra:
http://dk2.php.net/imagestring -> gannon (at) portablesofdoom (dot) org - 28-Dec-2006 03:53
function make_wrapped_txt($txt, $color=000000, $space=4, $font=4, $w=300)
{
if (strlen($color) != 6) $color = 000000;
$int = hexdec($color);
$h = imagefontheight($font);
$fw = imagefontwidth($font);
$txt = explode("\n", wordwrap($txt, ($w / $fw), "\n"));
$lines = count($txt);
$im = imagecreate($w, (($h * $lines) + ($lines * $space)));
$bg = imagecolorallocate($im, 255, 0, 0);
$color = imagecolorallocate($im, 0xFF & ($int >> 0x10), 0xFF & ($int >> 0x8), 0xFF & $int);
$y = 0;
foreach ($txt as $text)
{
$x = (($w - ($fw * strlen($text))) / 2);
imagestring($im, $font, $x, $y, $text, $color);
$y += ($h + $space);
}
header('Content-type: image/png');
die(imagepng($im));
}
if(isset($_POST['create']) && !empty($_POST['text']))
{
make_wrapped_txt($_POST['text'],'0000FF');
}
else
{
echo '<form action="804242exp.php" method="post">';
echo 'Tekst: <input type="text" name="text" /><br />';
echo '<input type="submit" name="create" value="Send Tekst" />';
echo '</form>';
}
?>