FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


looking for help with GD





damn
I am read about GD on php.net,
later I created to myself verification code with GD,
I am tried to change the font of GD, but with no success...
I read that I can load a font, but i ask that if i can to use usual font like "arial" for example.
plz help with the code...
thanks.
dangerdog
you have the font you're trying to use on the server, right?

working with the gd image libraries can be very difficult at time, troubleshooting can be particularly annoying, but you can do some amazing stuff with it.

i can probably help you out if you give me a little more details - you're trying to use a font that's not common? or you want to use something like arial? also, what's happening with it - are you getting output, just not in the font you want? or are you getting nothing at all?
blueray
Code:
header('content-type: image/png');
$image_width = 300;
$image_height = 100;
$font = 'e:\\winnt\\fonts\\arial.ttf';

$im = imagecreatefrompng($filename);
$bgc = imagecolorallocate($im, 255, 0, 0);
$tc = imagecolorallocate($im, 0, 0, 0);
imagefilledrectangle($im, 0, 0, $image_width, $image_height, $bgc);

imagettftext($im, 20, 0 /* clockwise angle */, 20, 70, $tc, $font, 'Demo pic');
imagepng($im);

imagedestroy($im);



I have used this code for my testing and excrise and it work without issues.
Check it out to see if it is help. Also, be use .png as the output format because
I have found the jpeg format was poor in quality. But png was OK.

Wish this help.
Agent ME
That... would only work on a windows nt system, wouldn't it? Most servers, including frihost, run on linux, don't they?
blueray
Agent ME wrote:
That... would only work on a windows nt system, wouldn't it? Most servers, including frihost, run on linux, don't they?


Yes, I'am using a windows system.

But it seems just replace the fonts location should be fine. ( Because gd was build with freetype, it's build-in support for TrueType font )
For instance, as following:

1.) copy a *.ttf font file to a dir that include the php script you would like to execute.
Code:
/www/arial.ttf
/www/gd.php


2.) modify the code as

Code:
$font = '/www/arial.ttf';

or simply

$font = 'arial.ttf';


[EDIT]
I have tested it and provides a small demo page. Just click the link provided.
Please let me known if the link does't work ( I have been tested it already, but just in a case that don't )

Go HERE or HERE to see a live demo


P.S : You should confirm that the system you are using be configured correctly
Related topics
[TUTOR] A Short Intro to GD
How To : Secure Your PHP Website
Help with creating a Frihost website.
Anybody needing help with HTML?
Help Needed Regarding CGI And Php
Programming Help & Support Guidelines
need help enabling GD php extension
GD Help
camera help please - what to buy and where to buy it...
Looking For This Software. Can AnyBody Help?
Making Games... (Looking for help)
How to Install GD in local apache server ? | hELP !!
Looking for some help
How to be a good shopkeeper on a retail shop [help!]
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.