Enlarge Signup Free Captcha – DaloRADIUS

Captcha Free Sign Up
Captcha Free Sign Up DaloRADIUS

By default, the Signup-Free of DaloRADIUS is designed to spit a captcha code as shown above.

The problem is, the above approach isn’t responsive, as in, it is difficult to enlarge the overall text size, which at the moment, looks really small.

Imagine viewing this slightly-pixelated autogenerated image on a smartphone screen. The legibility is very bad, obviously.

To fix it, how about we use the snippet below, which offers the opportunity to specify the font size, thus we can blow the size to as much big as we want.

You’ll include this snippet within the php-captcha.php file from here. You’ll know what to take out:


    $ResultStr = randomAlphanumeric(5);
    putenv('GDFONTPATH=' . realpath('.'));
    // Set the content-type
    header('Content-Type: image/png');

    // Create the image
    $im = imagecreatetruecolor(400, 40);

    // Create some colors
    $white = imagecolorallocate($im, 255, 255, 255);
    $grey = imagecolorallocate($im, 128, 128, 128);
    $black = imagecolorallocate($im, 0, 0, 0);
    // imagefilledrectangle(image, x1, y1, x2, y2, color)
    imagefilledrectangle($im, 0, 0, 399, 39, $white);

    // use local font
    $font = 'LinLibertine_R';

    $LineColor = imagecolorallocate($NewImage,233,239,239);     //line color 

    // draw lines on the image
    // imageline(image, x1, y1, x2, y2, color)

    // Add some shadow to the text
    // imagettftext(image, size, angle, x, y, color, fontfile, text)
    imagettftext($im, 25, 0, 11, 26, $grey, $font, $ResultStr);

    // Add the text
    imagettftext($im, 25, 0, 10, 25, $black, $font, $ResultStr);

    $_SESSION['key'] = $ResultStr;

    // Using imagepng() results in clearer text compared with imagejpeg()

The above is pretty straightforward, and I’ve left bit of comments, plus the syntax to give you an idea of what’s going on.

With the above, you get a result similar to this:

Responsive Captcha Sign Up Free
Responsive Captcha Sign Up Free – Daloradius

I hope the above helps you providing a better captcha image for users to look at and solve!

Thanks for joining me, and hope to see you in the next one!

Related Articles

Back to top button