Hi.
I've got this simple snippet:

<?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);
} 
$textstr = getRandom(8);
$font = "F:\WINDOWS\Fonts\ARIAL.TTF";
$bgurl = rand(1, 3);
$size = rand(12, 16);
$angle = rand(-5, 5);
$im = LoadJpeg("images/bg".$bgurl.".jpg");
$color = ImageColorAllocate($im, rand(0, 100), rand(0, 100), rand(0, 100));
$textsize = imagettfbbox($size, $angle, $font, $textstr);
$twidth = abs($textsize[2]-$textsize[0]);
$theight = abs($textsize[5]-$textsize[3]);
$x = (imagesx($im)/2)-($twidth/2)+(rand(-20, 20));
$y = (imagesy($im))-($theight/2);
ImageTTFText($im, $size, $angle, $x, $y, $color, $font, $textstr);
header( 'Content-Type: image/jpeg' );
imagejpeg($im);
imagedestroy($im);
?>

How can I give a slight distorting effect
to the font ?
By the way arial is a good one ?
Bye.

    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.

      Write a Reply...