Current location: Hot Scripts Forums » Programming Languages » PHP » Problem with GD


Problem with GD

Reply
  #1 (permalink)  
Old 07-28-06, 03:36 AM
azim azim is offline
New Member
 
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Problem with GD

Hi,

When I try to use following script on my own webserver running with apache2, php5 and GD.
Code:
 <?php
header("Content-type: image/png");
$im = @imagecreate(100, 50)
   or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  "A Simple Text String", $text_color);
imagepng($im);
imagedestroy($im);
?>
When I run the script it outputs

Code:
 Fatal error: Call to undefined function: imagecreatefromgd2() in /var/www/iipee.php on line 2
And this is what my php info GD-part looks like
Code:
gd

GD Support => enabled
GD Version => 2.0 or higher
FreeType Support => enabled
FreeType Linkage => with freetype
FreeType Version => 2.2.1
T1Lib Support => enabled
GIF Read Support => enabled
GIF Create Support => enabled
JPG Support => enabled
PNG Support => enabled
WBMP Support => enabled
When i try to run script without headers it outputs same error as before.

I installed gd package with debian apt.
Reply With Quote
  #2 (permalink)  
Old 07-29-06, 07:20 AM
UnrealEd's Avatar
UnrealEd UnrealEd is offline
Community Liaison
 
Join Date: May 2005
Location: Antwerp, Belgium
Posts: 3,165
Thanks: 4
Thanked 25 Times in 25 Posts
when i run your script, it works fine. there's probably something wrong with your gd configuration
here's mine:
Code:
GD Support => enabled
GD Version => bundled (2.0.28 compatible)
FreeType Support => enabled
FreeType Linkage => with freetype
GIF Read Support => enabled
GIF Create Support => enabled
JPG Support => enabled
PNG Support => enabled
WBMP Support => enabled
XBM Support => enabled
here's a link where you can see your script working:
http://downloads.cities-of-faith.com/public/test.php

Greetz,
UnrealEd
__________________
"Good judgement comes from experience, and experience comes from bad judgement." - Fred Brooks

Reply With Quote
  #3 (permalink)  
Old 07-29-06, 08:38 AM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
Which operating system is this on?

If you installed a compiled binary version of PHP, GD support is enabled, you do not need to do anything to get GD to work. If you did try to install a version of GD from elsewhere, I am with UnrealEd, your configuration now has a problem.

The PHP manual states that the imagecreatefromgd2() function requires GD 2.0.1 or later. Your configuration listing says 2.0 or higher. You could have 2.0.0, in which case the error message would be expected. The latest GD version bundled with PHP 5.1.4 is - 2.0.28

The function call in the error message is not the same function name in the code you posted (it is possible the function you are using makes use of the other internally, but PHP is usually very good about giving on target error messages.)
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
  #4 (permalink)  
Old 07-29-06, 09:02 AM
azim azim is offline
New Member
 
Join Date: Jul 2006
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Quote:
Originally Posted by mab
Which operating system is this on?

If you installed a compiled binary version of PHP, GD support is enabled, you do not need to do anything to get GD to work. If you did try to install a version of GD from elsewhere, I am with UnrealEd, your configuration now has a problem.

The PHP manual states that the imagecreatefromgd2() function requires GD 2.0.1 or later. Your configuration listing says 2.0 or higher. You could have 2.0.0, in which case the error message would be expected. The latest GD version bundled with PHP 5.1.4 is - 2.0.28

The function call in the error message is not the same function name in the code you posted (it is possible the function you are using makes use of the other internally, but PHP is usually very good about giving on target error messages.)
I have Debian and I installed gd using apt
Where can I find all the configuration files related to GD and PHP gd configuration files?
Reply With Quote
  #5 (permalink)  
Old 07-29-06, 10:08 AM
mab's Avatar
mab mab is offline
Community VIP
 
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
The only configuration file change is that php.ini must load the GD module, which it apparently is because of the entries listed in your phpinfo output. Other than that, there is nothing to configure.

What we both said was something is wrong with your configuration. From the latest PHP documentation, "there is no official Debian packages of PHP 5." http://us3.php.net/manual/en/install.unix.debian.php I suspect that the version of GD that you found and installed is not new enough to support the function you are using or it is not compatible with the PHP version or the operating system.
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Great, brandable domains for sale inc, Tootster.com planecrazy69 General Advertisements 2 10-11-06 10:12 AM
Yet another GD Image problem Ligx PHP 3 06-09-06 06:55 AM
[Merged]GD Image Output Problem Ligx PHP 11 06-07-06 08:58 AM
Count problem kasic ASP.NET 1 10-20-04 12:23 AM
Asp and Microsoft Access 2002 problem gop373 ASP 2 10-06-04 09:13 AM


All times are GMT -5. The time now is 07:22 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.