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.