0

Hello Daniweb Members,

I am currently trying to develop a Captcha for my website, I have a wacky font that shall hopefully make it harder for bots to read, and I was planning on using the imagefttext() function to display it.

Currently I have the following (Doesn't Randomly Generate String Yet):

<?php

    Header ("Content-Type: image/png");

    $Image = @imagecreate(200, 30)
        or die ("Cannot Initialise GD Image Stream");

    $Background_1 = mt_rand(100, 250);
    $Background_2 = mt_rand(100, 250);
    $Background_3 = mt_rand(100, 250);

    $Background_Colour = imagecolorallocate($Image, $Background_1, $Background_2, $Background_3);

    $Text_1 = mt_rand(1, 150);
    $Text_2 = mt_rand(1, 150);
    $Text_3 = mt_rand(1, 150);

    $Text_Colour = imagecolorallocate($Image, $Text_1, $Text_2, $Text_3);

    $Font = $_SERVER['DOCUMENT_ROOT'].'/Assets/Fonts/Ed_Gein_Gwilty.ttf';

    imagefttext($Image, 10, 65, 7, $Text_Colour, $Font, "Testing");
    imagepng($Image);
    imagedestroy($Image);

?>

It shall produce the random coloured box, but it won't display the text. I have double checked my paths and ini_set('display_errors','1'); doesn't show up with any issues.

I have GD and Freetype enabled on the server.

Any help would be appreciated, thank you!

2
Contributors
2
Replies
3
Views
4 Years
Discussion Span
Last Post by Dani
0

Thread Closed - Worked it out... the text was positioned too far out of the box. Realised I was measuring from the wrong point!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.