gd library
Moderator: General Moderators
gd library
Is anyone using the gd library with PHP? If so, how do I install it? I've read the documentation, but it's not very clear to me what I'm supposed to do. Do I really have to compile C code? Sorry if this is a dumb question, but I'm finding this more difficult than it seems like it should be.
Thanks,
Jason
Thanks,
Jason
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
http://ca.php.net/gd read the installation section
Well, turns out we have PHP 4.3.9 here, but I wasn't the one who installed it. Apparently, the gd library has been installed, but there was only one script that used it and it gave me some errors when I tried to test it. However, these errors came from an include file and were not gd-related.
Just now, I grabbed a little test thing from php.net:
I called it button.php and made another file like this:
Just like it said to. I changed the "images/button1.jpg" to point to an image that actually exists, too. I didn't get any errors, which implies the gd library is working, but this script just resulted in a broken image. Any ideas?
Just now, I grabbed a little test thing from php.net:
Code: Select all
<?php
header("Content-type: image/png");
$string = $_GET['text'];
$im = imagecreatefrompng("images/button1.png");
$orange = imagecolorallocate($im, 220, 210, 60);
$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
imagestring($im, 3, $px, 9, $string, $orange);
imagepng($im);
imagedestroy($im);
?>Code: Select all
<img src="button.php?text=text">- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
Well, I went to button.php directly with the header information commented out and it told me:
What do I need to do to fix this?
Thanks,
Jason
Code: Select all
Fatal error: Call to undefined function: imagecreatefrompng() in c:\wwwroot\button.php on line 5Thanks,
Jason
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
Well, it looks like you don't have the gd library installed in PHP.
Execute one of these small scripts.
or
This will give you a list of the installed GD modules.
["PNG Support"] => bool(true)
Will be shown if the PNG module is installed. If the GD library isn't installed in PHP then you will get the "GD Library not installed" message.
Execute one of these small scripts.
Code: Select all
<?php
if(function_exists("gd_info"))
var_dump(gd_info());
else
echo "GD Library not installed";
?>Code: Select all
<?php
if(function_exists("gd_info"))
print_r (gd_info());
else
echo "GD Library not installed";
?>["PNG Support"] => bool(true)
Will be shown if the PNG module is installed. If the GD library isn't installed in PHP then you will get the "GD Library not installed" message.
That resulted in "GD Library not installed", which reverts us back to my original post. Someone posted a link to the php.net installation instructions, but I don't fully understand them. For example, it says:
Thanks,
Jason
I don't know what "configure PHP --with-gd[=DIR]" means. One thought is that it a step that is taken in the PHP installation process, in which I did not participate. I un-commented the line in php.ini that reads "extension=php_gd2.dll" but it made no difference. I wasn't all that surprised by this since I don't really know what I'm doing, anyway. Can someone possibly put the installation process in simple terms for me?To enable GD-support configure PHP --with-gd[=DIR], where DIR is the GD base install directory. To use the recommended bundled version of the GD library (which was first bundled in PHP 4.3.0), use the configure option --with-gd. GD library requires libpng and libjpeg to compile.
In Windows, you'll include the GD2 DLL php_gd2.dll as an extension in php.ini. The GD1 DLL php_gd.dll was removed in PHP 4.3.2. Also note that the preferred truecolor image functions, such as imagecreatetruecolor(), require GD2.
Thanks,
Jason
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
Also....
Follow me....
My Computer >> Right Click >> scroll down to >> Properties >> Left Click
Top of... >> System Properties >> Left Click >> Advanced >> Go Down To >> Environment Variables >> Left Click
Lower Window >> Highlight Variable * Path * >> Left Click the * Edit Button * below that window! Go to the beginning of * Variable Value * place your cursor there, then type!
c:\php\dlls;
If that is the path to your PHP * dlls folder * remember type exactly what is above including the semicolon (the path must not end with * \ * it must be the directory name, in this cae * dlls *)
Left Click * OK * 3 times, restart Apache, IIS or what ever you are using...
yj
Follow me....
My Computer >> Right Click >> scroll down to >> Properties >> Left Click
Top of... >> System Properties >> Left Click >> Advanced >> Go Down To >> Environment Variables >> Left Click
Lower Window >> Highlight Variable * Path * >> Left Click the * Edit Button * below that window! Go to the beginning of * Variable Value * place your cursor there, then type!
c:\php\dlls;
If that is the path to your PHP * dlls folder * remember type exactly what is above including the semicolon (the path must not end with * \ * it must be the directory name, in this cae * dlls *)
Left Click * OK * 3 times, restart Apache, IIS or what ever you are using...
yj
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact:
- AKA Panama Jack
- Forum Regular
- Posts: 878
- Joined: Mon Nov 14, 2005 4:21 pm
If you make any changes to the php.ini you have to restart apache for the changes to take effect. Apache will reload PHP when it is restarted.n00b Saibot wrote:There have been posts above which indicate that restarting Apache is necessary but I don't think it to be necessary... all it needs is uncommenting the particular line, saving the ini and a F5(refresh)and yes, I have pretty much personal exp. to back that statement
- n00b Saibot
- DevNet Resident
- Posts: 1452
- Joined: Fri Dec 24, 2004 2:59 am
- Location: Lucknow, UP, India
- Contact: