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!

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

Hah! Glad you got it figured out. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.