webproclaim Posted August 16, 2006 Share Posted August 16, 2006 I wrote this script that creates an image and then places a random string of characters on the image and runs a line thru them. (This is something I use along with forms to block bots from auto posting them if you are interested). Anyway, I just setup a new server and now this script it does not work properly. It creates the image and the line in the image, but the text does not appear on the image. I verified that the times.ttf file is the the proper place. Also, this new server is running the same version of PHP as my other server where this script works (even using an identical copy of the php.ini file).I just cant seem to figure out why this would work on one server and not the other. It has to be something system related but I just can't figure it out. Any help with this would be appreciated.<?php $TheImage = Imagecreate("75", "25"); $ColorImage = imagecolorallocate($TheImage, 180, 50, 23); $ColorText = imagecolorallocate($TheImage, 0, 0, 0);$ColorLine = imagecolorallocate($TheImage, 75, 75, 75); $secret = substr(md5(uniqid(rand())), 0, 5);$secret = strtoupper($secret);session_start();session_register("Dingy");$Dingy = $secret;imageline($TheImage, 75, 8, 0, 15, $ColorLine);ImageTTFText($TheImage, 12, -5, 16, 20, $ColorText, "times.ttf", $secret); header("Content-Type: image/PNG"); ImagePng ($TheImage); imagedestroy($TheImage);?> Quote Link to comment https://forums.phpfreaks.com/topic/17736-gd2-and-ttf/ Share on other sites More sharing options...
bbaker Posted August 16, 2006 Share Posted August 16, 2006 from the imagettftext documentation on php.net [url=http://us2.php.net/manual/en/function.imagettftext.php]http://us2.php.net/manual/en/function.imagettftext.php[/url][quote]Depending on which version of the GD library PHP is using, when fontfile does not begin with a leading / then .ttf will be appended to the filename and the library will attempt to search for that filename along a library-defined font path.[/quote]maybe try dropping the .ttf in your ImageTTFText function?[code]ImageTTFText($TheImage, 12, -5, 16, 20, $ColorText, "times", $secret); [/code] Quote Link to comment https://forums.phpfreaks.com/topic/17736-gd2-and-ttf/#findComment-75691 Share on other sites More sharing options...
webproclaim Posted August 16, 2006 Author Share Posted August 16, 2006 bbaker,I tried it without the '.ttf' and it still doesnt work. It is like the ImageTTFText function is broken. Quote Link to comment https://forums.phpfreaks.com/topic/17736-gd2-and-ttf/#findComment-75692 Share on other sites More sharing options...
webproclaim Posted August 16, 2006 Author Share Posted August 16, 2006 More info...Looking at the PHP errors...the problem is that it cannot see the font. The font IS in the correct place though. I am running this on Windows 2003 Server. Any idea why PHP can't see the font? It's in the same directory as the file.Warning: Could not find/open font in C:\!Webs\mysite\codekeyimage.php on line 31 Quote Link to comment https://forums.phpfreaks.com/topic/17736-gd2-and-ttf/#findComment-75696 Share on other sites More sharing options...
webproclaim Posted August 21, 2006 Author Share Posted August 21, 2006 Any ideas anyone? I have yet to solve this.This is one of those off PHP things that happen every so often that make me want to pull my hair out (what's left of it). Quote Link to comment https://forums.phpfreaks.com/topic/17736-gd2-and-ttf/#findComment-78208 Share on other sites More sharing options...
HuggieBear Posted August 22, 2006 Share Posted August 22, 2006 Don't forget to check the case. The link to the font file will be CaSe SeNsitiVe.Sometimes this gets overlooked, so your code is looking for times.ttf and the file is called Times.ttf or Times.TTFRegardsRich Quote Link to comment https://forums.phpfreaks.com/topic/17736-gd2-and-ttf/#findComment-78499 Share on other sites More sharing options...
webproclaim Posted August 22, 2006 Author Share Posted August 22, 2006 Rich,In this particular case, the problem cannot be with anything in the code. Everything worked fine before we reformatted and resetup our server.I have the exact same code running on a different server along with the same php.ini file and exact copy of the DLL for GD2. Quote Link to comment https://forums.phpfreaks.com/topic/17736-gd2-and-ttf/#findComment-78572 Share on other sites More sharing options...
webproclaim Posted August 22, 2006 Author Share Posted August 22, 2006 How about this...Is there any otrher way for me to get text to be displayed on my image WITHOUT having to use ImageTTFText. Can I write text in an image without using a TTF? Quote Link to comment https://forums.phpfreaks.com/topic/17736-gd2-and-ttf/#findComment-78574 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.