How can I resize this Captcha Image?

How can I resize this Captcha Image ( and add padding)? Here’s the code:

<?php
session_start();
$code=rand(1000,9999);
$_SESSION["code"]=$code;
$im = imagecreatetruecolor(50, 24);
$bg = imagecolorallocate($im, 177, 78, 78); //background color red
$fg = imagecolorallocate($im, 255, 255, 255);//text color white
imagefill($im, 0, 0, $bg);
imagestring($im, 5, 5, 5,  $code, $fg);
header("Cache-Control: no-cache, must-revalidate");
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>

Any help will be appreciated

The answer is here

Thanks for your reply. Very helpful.

However, I can’t seem to get it to line up with the rest of the horizontal line (see attached image).
As you can see it appears to be a bit lower than the rest of the line.
Here’s the code:

<td class="captcha">ENTER IMAGE TEXT:&nbsp;&nbsp;<input name="captcha" style="width:100px" type="text" required/>&nbsp;&nbsp;<img src="captcha.php" /></td>

and:

<style>
td.captcha {
width: 600px;
height: 90px;
border: 1px solid #b14e4e;
border-width: 0px 0px 1px 1px;
font-family: arial, helvetica, sans-serif;
font-size: 25px;
background: #;
padding: 26px 0px 5px 50px;
color:#b14e4e;
margin: 0px auto;
}
</style>

Any help with getting it to line up more centered with the rest of the line will be appreciated.

I don’t see any attached image. However, if they don’t align vertically you might need to apply td.captcha img { vertical-align: some-value; }. Play around with some-value till you get the required result.

1 Like

Thanks alot

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.