I worked it out not very hard :rolleyes:
<?php
error_reporting(E_STRICT | E_ALL);
function LoadJpeg($imgname)
{
$im = @imagecreatefromjpeg($imgname); /* Attempt to open */
if (!$im) { /* See if it failed */
$im = imagecreatetruecolor(150, 30); /* Create a black image */
$bgc = imagecolorallocate($im, 255, 255, 255);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, 150, 30, $bgc);
/* Output an errmsg */
imagestring($im, 1, 5, 5, "Error loading $imgname", $tc);
}
return $im;
}
function getRandom($stringLength)
{
if(!is_numeric($stringLength))
{
exit('Invalid parameter');
}
$chars = array_merge(range(0, 10),range('a', 'z'),range('A', 'Z'));
shuffle($chars);
return substr(implode($chars), 0,$stringLength);
}
function GetColor( $im )
{
$colorsValue = array_merge(range ( 10, 200 ),range ( 10, 200 ),range ( 10, 200 ));
shuffle ( $colorsValue );
$tmp = array_slice($colorsValue, 0, 3);
$color = ImageColorAllocate($im, $tmp[0], $tmp[1], $tmp[2]);
return $color;
}
function GetGrad()
{
$grad = range ( -45, 45 );
shuffle ( $grad );
return $grad[1];
}
$FONT = "font/arial.TTF";
$im = LoadJpeg("images/mio.jpg");
$text = getRandom(8);
$text_count = strlen($text);
$step = 15; // Startwert
for ( $i = 0; $i < $text_count; $i++)
{
$size = rand(12, 16);
$TS = imagettfbbox( $size, 0, $FONT, $text[$i] );
$x = abs($TS[2]-$TS[0]);
if ($x < 13){ $x = 15;}
ImageTTFText($im, $size, GetGrad(), $step, 30, GetColor( $im ), $FONT, $text[$i] );
$step += ($x+2);
}
ImageJPEG ($im, '$$$.jpg', 20); //
ImageDestroy($im);
echo '<img src="$$$.jpg?'.time().'" border="1">';
?>
Bye.