General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old January 4th, 2003, 03:36 PM
lcp2000 lcp2000 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 4 lcp2000 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Help with Random Image...

Hi guys, I'm having trouble with the following code.
Everything works fine if I use only the Imagestring
function but not with the Imagettftext function.

Are there any special requirements to use the
Imagettftext function?

Hope you can help.
LCP

PHP Code:
<?php

//random_number.php
$img_number imagecreate(100,50);
$white imagecolorallocate($img_number,255,255,255);
$black imagecolorallocate($img_number,0,0,0);
$grey_shade imagecolorallocate($img_number,204,204,204);

imagefill($img_number,0,0,$grey_shade);
ImageRectangle($img_number,5,5,94,44,$black);
ImageRectangle($img_number,0,0,99,49,$black);

$number get_random();

//Imagestring($img_number,9,30,15,$number,$black);
Imagettftext($img_number30,0,10,33,$black,'trebuchet.ttf',$number);

header("Content-type: image/jpeg");
imagejpeg($img_number);

function 
get_random()
{
srand(time());
$max getrandmax();
return 
rand(1,$max) + rand(1,$max);


?>

Reply With Quote
  #2  
Old January 5th, 2003, 04:46 AM
Jeb. Jeb. is offline
"l33t? What's l33t?"
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 51 Jeb. User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via AIM to Jeb.
Make sure your font file is the in the same directory as your script, or if it isn't, ensure the path in imagettftext() is pointing to the correct location.
__________________
Jeb.

AIM: JebediahMc - PM Me - E-Mail Me


Reply With Quote
  #3  
Old January 5th, 2003, 10:35 AM
lcp2000 lcp2000 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 4 lcp2000 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The font file is there but I get the following error:

Fatal error: Call to undefined function: imagettftext() in /home/user/public_html/random_number.php on line 16

Thanks.

Reply With Quote
  #4  
Old January 5th, 2003, 07:20 PM
jpenn jpenn is offline
Contributing User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Oct 2002
Location: Washington, DC
Posts: 317 jpenn User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 m 3 sec
Reputation Power: 7
PHP Code:
 Fatal errorCall to undefined function: imagettftext() 

98% of the time that error string means the function is not loaded or the library itself is not loaded. The other 2% of the time the function has been disabled by the host.

Lets first make sure you have the library (GD) installed. Run this sniplet ->

PHP Code:
 $loaded = ( bool ) false;
$lib 'GD';
$data get_loaded_extensions();
foreach ( 
$data as $val )
    {
    if ( 
stristr$val$lib ) ) {
        
$loaded true;
    }
    echo 
$val '<br /><br />';
}
if ( 
$loaded ) {
    echo 
'<strong>' $lib ' is loaded';
} else {
    echo 
'<strong>' $lib ' is not loaded loaded';



See what that returns. It will show your installed libraries and print weather GD is installed or not.

If GD is installed - I would call your host and ask them why the function was disabled - if thats the case...
__________________
~ Joe Penn

We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set?

Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you.




Reply With Quote
  #5  
Old January 5th, 2003, 11:32 PM
lcp2000 lcp2000 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 4 lcp2000 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks for your reply, this is the output.
I'll check to see why it was dissabled.


xml
wddx
standard
session
posix
pcre
openssl
mysql
mhash
mcrypt
mbstring
gd
ftp
curl
ctype
calendar
bcmath
zlib
Zend Optimizer
apache

GD is loaded

Thanks.

Reply With Quote
  #6  
Old January 5th, 2003, 11:37 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
does the version of GD that you are running support that function?

Reply With Quote
  #7  
Old January 6th, 2003, 12:23 AM
Jeb. Jeb. is offline
"l33t? What's l33t?"
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 51 Jeb. User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via AIM to Jeb.
Quote:
Originally posted by lcp2000
The font file is there but I get the following error:

Fatal error: Call to undefined function: imagettftext() in /home/user/public_html/random_number.php on line 16

Thanks.


My apologies, I didn't read what you said close enough.

Reply With Quote
  #8  
Old January 6th, 2003, 02:19 AM
lcp2000 lcp2000 is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 4 lcp2000 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Np.

It seems that the problem may be due to the legal issues
with .gif creation on the new versions of PHP.

If so,

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Help with Random Image...


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT