Matt Belcaustier
Matt Belcaustier

Reputation: 39

Not rendering my image correctly

I tried to make a captcha image rendering a random text (look at my $_SESSION["captcha"]).

It's working perfectly on my localhost with WAMP, but on my website it shows only a transparent 64x20 image, no text on, nothing.

I had an error 500 before and I installed php5-gd + restarted Apache, maybe I missed something to install?

I don't have access to my (error) logs.

Here is my code :

<?php

session_start();

$_SESSION["captcha"] = mt_rand(100, 999);
$img = imagecreatetruecolor(64, 20);
$font = "Inversionz.otf";

imagealphablending($img, true);
imagesavealpha($img, true);

imagefill($img, 0, 0, 0x7fff0000);
$textcolor = imagecolorallocate($img, 0, 0, 0);

imagettftext($img, 27, 0, 0, 20, $textcolor, $font, $_SESSION["captcha"]);

header("Content-type:image/png");
imagepng($img);
imagedestroy($img);

?>

My font (Inversionz.otf) is uploaded.

Upvotes: 1

Views: 44

Answers (1)

Matt
Matt

Reputation: 5428

Alright, you made me go find that font and run it locally. :)

I had the same error you're having until...

Drumroll please.

I added ./ to the path. $font = "./Inversionz.otf";

Upvotes: 1

Related Questions