Log in

View Full Version : Gd



InNeedofHelp
07-23-2006, 09:42 PM
Can somebody please help me get my GD library installed? I've been to php.net and tried from them but i'm just really confused. I'm currently running WindowsXP, and have downloaded a GD library from this site:

http://www.boutell.com/gd/

Any help would be great.
Thanks. :D

Twey
07-23-2006, 11:16 PM
You evidently didn't read the chain of documentation correctly :)
php 4.3.x is available, and it includes a version of gd as "standard equipment." php_gd2.dll is included in a standard PHP installation for Windows, it's just not enabled by default. To turn it on, the user may simply uncomment the line "extension=php_gd2.dll" in php.ini and restart the PHP extension. Change:
#extension=php_gd2.dllTo:
extension=php_gd2.dllYou may also have to correct the extension directory setting from:
extension_dir = "./"Or:
extension_dir = "./extensions"To (FOR WINDOWS):
extension_dir = "c:/php/extensions"NOTE: SUBSTITUTE THE ACTUAL PHP INSTALLATION DIRECTORY ON *YOUR* COMPUTER.

InNeedofHelp
07-23-2006, 11:31 PM
You know, sometimes i feel so stupid. Well thanks for clearing this up for me Twey. :D

InNeedofHelp
07-24-2006, 12:03 AM
Ok so my GD is installed just as you showed above, yet my images dont show. Any Idea why that is?

jr_yeo
07-24-2006, 12:06 AM
probably ImageMagick :p

Twey
07-24-2006, 12:18 AM
Ok so my GD is installed just as you showed above, yet my images dont show. Any Idea why that is?If you access your image-generating pages directly, you'll be able to see the errors.
probably ImageMagick :pImageMagick and gd are two totally seperate libraries.

InNeedofHelp
07-24-2006, 01:00 AM
When i access the only page i have that makes the image, nothing shows up. Do I have to download each of the libraries at www.php.net/gd ? I mean like the Font librarys and such.

Also, when i do print_r(gd_info()) nothing shows up.

Twey
07-24-2006, 01:31 AM
Try:
error_reporting(E_ALL);at the top of your page.

InNeedofHelp
07-24-2006, 02:07 AM
The page turns out blank, just like before. :confused:

Twey
07-24-2006, 02:11 AM
Try not setting the Content-Type header.

InNeedofHelp
07-24-2006, 02:34 AM
No change.

At php.net it shows a table about image formats. And it shows a couple libraries to download for each format. Do i need those downloaded too? And the Font libraries?

InNeedofHelp
07-24-2006, 02:40 AM
Oh, i think i'm onto something here, before i put the error_all thing that you suggested, and before i took out the header, the image was just the box with an X in it. So i was reading at php.net, and it says that to put the image in png format you need to donwload another library. well in my script the image is output as a png. So i tried instead of using imagepng($im) i used imagejpeg($im), but still just a box with an X. :o

Twey
07-24-2006, 02:47 AM
The box with the X just means that your script isn't actually outputting a perfectly-formed image. Can you post the script?

InNeedofHelp
07-24-2006, 02:51 PM
Allright, well this code i took from www.php.net to test my computer and see if i had the GD thing properly installed and whatnot, so i don't really understand it, and that may be why my image wont show.


<?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);
imagejpeg($im);
imagedestroy($im);
?>

Twey
07-24-2006, 02:56 PM
Well, that looks fine to me. Find out where your php_gd2.dll file resides, and check that your php.ini points to it correctly.

/EDIT: Actually, try this first:
<?php if(function_exists('imagecreate')) die('GD is working.'); else die('GD isn't working.'); ?>

InNeedofHelp
07-24-2006, 03:44 PM
The page is now blank again.
The directory is pointed in the right place for where php_gd2.dll is located.
I tried changing the code to see if my page would change to be the box with the X instead of blank. Here's my code now:


<?php

$im = imagecreate(100, 100);

$string = 'PHP';

$bg = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);

// prints a black "P" in the top left corner
imagechar($im, 1, 0, 0, $string, $black);

header('Content-type: image/png');
imagepng($im);

?>
<?php if(function_exists('imagecreate')) { die('GD is working.');} else { die('GD isn't working.');} ?>


Again, that was taken from www.php.net since i dont know how to script it quite yet.

Twey
07-24-2006, 03:54 PM
No no, not after the rest of the code, I intended you to put that code in a separate page.

InNeedofHelp
07-24-2006, 04:02 PM
Oh.
Hahah, I didn't catch this before: the code you told me to put in was missing something, no wonder it didnt work.


<?php if(function_exists('imagecreate')) { die('GD is working.');} else { die('GD isn't working.');} ?>


The second die() function - 'isn\'t'. Hehe, no wonder it wasn't working.

Anyway, i put that code in a separate page, and it turns out GD isn't working.

Twey
07-24-2006, 04:03 PM
Whoops, yeah, sorry.

Where is php_gd2.dll? What are the pertinent lines of php.ini?

InNeedofHelp
07-24-2006, 04:15 PM
I dont know what pertinant means, but i'm assuming you want to see the lines in my php.ini that show you exactly where GD is located:


extension_dir = "c:\web\php\extensions"

then later in php.ini


extension=php_gd2.dll

and thats it.

Twey
07-24-2006, 04:36 PM
And php_gd2.dll is c:\web\php\extensions\php_gd2.dll?

InNeedofHelp
07-24-2006, 04:47 PM
Yeah.

InNeedofHelp
07-24-2006, 07:00 PM
Ok, so i tried this on my other computer:

echo gd_info();

And it outputted something that may be useful, but for some reason it wouldnt output this on my regular computer.


Fatal error: Call to undefined function: gd_info() in c:\web\htdocs\gdinfo.php on line 4

Does that help at all?

Twey
07-24-2006, 07:33 PM
No, just means gd isn't working properly :)
I suggest you try somewhere that specialises in this sort of thing, like #apache (irc://freenode/%23apache) on Freenode (link may not work, don't know how the forum will like irc:// links).

InNeedofHelp
07-24-2006, 07:40 PM
My browser wont access the site, neither from the link nor from trying to enter it in the URL. :o

NXArmada
07-24-2006, 08:00 PM
you need an IRC client in order for that link to work. like X-Chat (http://xchat.org/windows/)