...

View Full Version : No text outputting in GD



kaisellgren
01-30-2007, 03:33 PM
Hi,

When I use the following code to generate image with GD:


<?php

header("Content-type: image/png");
$image = imagecreate(256,50);
$color = imagecolorallocate($image,255,255,0);
$color2 = imagecolorallocate($image,255,0,0);
imagefill($image,0,0,$color2);
imagettftext($image,25,0,25,15,$color,"arial","test");
imagepng($image);
imagedestroy($image);

?>It works on my own server, but when I test it at ByetHost it does not work. It only outputs a red image without the text. For some reason the text is not outputted into the image. I asked support from ByetHost but they just keep saying the function imagettftext() works well.

Any help?

angst
01-30-2007, 03:49 PM
might just be a difference in versions between what your running and what they're running,

if they say it works the same, ask them if they can put up a small example on your site.

Len Whistler
01-30-2007, 04:47 PM
Your website should have an "admin" folder that you access to check on how your site is running, such as the IP address's of visitors and where they come from, etc. I also have this code in the "admin" folder.


<?php
phpinfo();
?>

To check on the version of PHP and how it is setup.

angst
01-30-2007, 04:53 PM
actually you should be able to run that from anywhere on the site.

kaisellgren
01-30-2007, 04:55 PM
Okay. I made it E_ALL, the error reporting I mean.

Now I have figured out that the script couldn't load font...

jimjamjo1
01-30-2007, 05:49 PM
the ttf font file needs to be included with the script, ie: in the same folder

angst
01-30-2007, 05:52 PM
it can be in any folder, but requires a system path to the file.

kaisellgren
01-30-2007, 06:23 PM
Umm,

This is the code:

<?php
error_reporting(E_ALL); ini_set('display_errors', true);

$image = imagecreate(256,50);
$color = imagecolorallocate($image,255,255,0);
$color2 = imagecolorallocate($image,255,0,0);
imagefill($image,0,0,$color2);
imagettftext($image,25,0,25,15,$color,"tahoma.ttf","test");

if ( !headers_sent() ) {
header("Content-type: image/png");
imagepng($image);
}
imagedestroy($image);
?>And I have uploaded tahoma.ttf in the same directory where the script is. Still cannot load/find font?

angst
01-30-2007, 06:25 PM
I just loaded it on my server and it runs fine.
but I used "ARIAL.ttf"



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum