Jul 25, 2008

Php And Gd

Free Web Hosting, No Ads > General > Hosted Members Area

free web hosting

Php And Gd

tehyev
So, today I was trying out a tutorial on making a dynamic image using PHP. So i followed all the steps correctly, upload it to my site and I get there errors

QUOTE
Warning: imagettfbbox(): Could not find/open font in /home/tehyev/public_html/fortune.php on line 16

Warning: Cannot modify header information - headers already sent by (output started at /home/tehyev/public_html/fortune.php:16) in /home/tehyev/public_html/fortune.php on line 20

Warning: imagettftext(): Could not find/open font in /home/tehyev/public_html/fortune.php on line 25


Does anyone know how to fix it?

Reply

Saint_Michael
what tutorial are you using? with the font error I assume you would need a font file that you are using and that should fix it. But if you can provide a link to the tutorial that will make the question easier to answer.

Reply

tehyev
QUOTE(Saint_Michael @ Oct 23 2006, 09:58 PM) *

what tutorial are you using? with the font error I assume you would need a font file that you are using and that should fix it. But if you can provide a link to the tutorial that will make the question easier to answer.

http://www.gurusnetwork.com/tutorial/php_gd/

and i have uploaded the font file

Reply

BuffaloHELP
It is VERY hard to determine what the possible error could be without seeing your actual script file. Try attaching it in the post.

But just for the fun, if you used the exact copy of the complete script, try making change to the following line:

Line #2
CODE
$font_file = $_SERVER['DOCUMENT_ROOT']."../path/verdana.ttf";


Note the double "period" in case you didn't place the font under the folder called "path". BTW you created a folder called "path" or other and change it accordingly?

Reply

Saint_Michael
CODE
$font_file = $_SERVER['DOCUMENT_ROOT']."/path/verdana.ttf";


Well I looked at the coding I would believe that the error lies with this line. The path to the font file put the full path that leads to the font file and see if that works.

Reply

tehyev
QUOTE(BuffaloHELP @ Oct 23 2006, 10:41 PM) *

It is VERY hard to determine what the possible error could be without seeing your actual script file. Try attaching it in the post.

But just for the fun, if you used the exact copy of the complete script, try making change to the following line:

Line #2
CODE
$font_file = $_SERVER['DOCUMENT_ROOT']."../path/verdana.ttf";


Note the double "period" in case you didn't place the font under the folder called "path". BTW you created a folder called "path" or other and change it accordingly?

Originally I followed the tutorial and typed everything in notepad, but it gave me a lot of errors so I tried that code. And I made a folder called "fonts" and uploaded Verdana to there, and changed the path accordingly.

@ Saint Michael, I tried putting the full path "home/tehyev/public_html/fonts/verdana.ttf" and it didn't work either.

 

 

 


Reply

electron
Well i used that in my old server and it used to work.
Tap17 has a better version than that of my old server.
There is some error in your script.
Post it and we will find the error.

Reply

tehyev
QUOTE(electron @ Oct 24 2006, 04:22 AM) *

Well i used that in my old server and it used to work.
Tap17 has a better version than that of my old server.
There is some error in your script.
Post it and we will find the error.

CODE
<?php

// Set the static variables (discussed in step 3)
$font_file = $_SERVER['DOCUMENT_ROOT']."/home/tehyev/public_html/fonts/Verdana.TTF";
$font_size = 8;
$y_start = 53;
$angle = 0;
$max_width = 300;

// Retrieve random fortune from text file (discussed in step 2)
$fortune_array = file("fortunes.txt");
srand((double) microtime() * 10000000);
$fortune = array_rand($fortune_array);

// Calculate horizontal starting point for the text (discussed in step 3)
$line_width = imagettfbbox($font_size, 0, $font_file, $fortune_array[$fortune]);
$x_start = (($max_width - $line_width[2] - $line_width[0]) / 2) + 50;

// Create the image resource and assign colors to variables (discussed in steps 1 and 5)
header("Content-type: image/png");
$im = imagecreatefrompng("blank.png");
$red = imagecolorallocate($im, 255, 0, 0);

// Write the text to the image (discussed in step 4)
imagettftext($im, $font_size, $angle, $x_start, $y_start, $red, $font_file, $fortune_array[$fortune]);

// Create and then destroy the image (discussed in steps 5 and 6)
imagepng($im);
imagedestroy($im);
?>


Theres the script.

Reply

jlhaslip
Original first lines :
CODE

$font_file = $_SERVER['DOCUMENT_ROOT']."/home/tehyev/public_html/fonts/Verdana.TTF";
$font_size = 8;

Change to:
CODE

echo $_SERVER['DOCUMENT_ROOT'];
$font_file = $_SERVER['DOCUMENT_ROOT']."/home/tehyev/public_html/fonts/Verdana.TTF";
echo $font_file;

Check that you aren't duplicating a folder name in there someplace.
I am guessing that you might need to knock some of the path from this part:
CODE
/home/tehyev/public_html/fonts/Verdana.TTF

Reply

tehyev
QUOTE(jlhaslip @ Oct 24 2006, 02:01 PM) *

Original first lines :
CODE

$font_file = $_SERVER['DOCUMENT_ROOT']."/home/tehyev/public_html/fonts/Verdana.TTF";
$font_size = 8;

Change to:
CODE

echo $_SERVER['DOCUMENT_ROOT'];
$font_file = $_SERVER['DOCUMENT_ROOT']."/home/tehyev/public_html/fonts/Verdana.TTF";
echo $font_file;

Check that you aren't duplicating a folder name in there someplace.
I am guessing that you might need to knock some of the path from this part:
CODE
/home/tehyev/public_html/fonts/Verdana.TTF


So that got rid of the two messages at the top. Now it has:

CODE
/home/tehyev/public_html/home/tehyev/public_html/fonts/Verdana.TTF
Warning: Cannot modify header information - headers already sent by (output started at /home/tehyev/public_html/fortune.php:4) in /home/tehyev/public_html/fortune.php on line 21


How can I fix that?

Reply



Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : php gd


    Looking for php, gd

Searching Video's for php, gd
advertisement



Php And Gd



 

 

 

 

ADD REPLY / Got an Opinion! Remove these ADs! RAPID SEARCH! Free Web Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE