Jump to content

changing font size in security image code


biblestamps

Recommended Posts

Hello.  I have a security image that is working but it is a simple black box with white text in it.  I realize that isn't the best and would like to do a colored background with slightly distorted letters.  I found the code posted below and I am happy with how it looks for the most part.  I was able to edit it enough to get it to work in my current system...BUT the text in the image is just too small and I do not understand this coding well enough to figure out if I can change the font size or how. Thank you for taking a look at it.

 


<?php
session_start();

$w = 120; // height of the image
$h = 40; // width of the image
$l = 5; // length of security code
$baseList = '0123456789abcdfghjkmnpqrstvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; // the characters to be used when generating the code

$code = "";
$counter = 0;

$img = @imagecreate($w, $h) or die('Cannot initialize GD!'); // create image

for ($i = 0; $i < 10; $i++)
{
imageline($img, mt_rand(0, $w), mt_rand(0, $h), mt_rand(0, $w), mt_rand(0, $h),
	imagecolorallocate($img, mt_rand(150, 255), mt_rand(150, 255), mt_rand(150, 255)));
}

for ($i = 0, $x = 0; $i < $l; $i++)
{
$randChar = substr($baseList, rand(0, strlen($baseList) - 1), 1);
$x += 10 + mt_rand(0, 10);
imagechar($img, mt_rand(3, 5), $x, mt_rand(5, 20), $randChar, imagecolorallocate
	($img, mt_rand(0, 155), mt_rand(0, 155), mt_rand(0, 155)));
$code .= strtolower($randChar);
}

header('Content-Type: image/jpeg');
imagejpeg($img);
imagedestroy($img);

$_SESSION['secCode'] = $code;

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.