Click to See Complete Forum and Search --> : Problem using GD library on windows 98
I have installed PHP3 and PHP4 on Windows 98 platform, both are working fine. Now I want to use IMAGE GENERATION capability of PHP. I have downloaded GD, zlib, jpg, png librares but I do not know how to get them worked with PHP. I looked through a number of documents and books but I failed to get Windows specific details on how to use GD library on windows platform. I would be very grateful if any one help me in this direction with coprehensive details.
I had this problem. All the GD libraries and stuff come in written as C source code as I understand it. This is a Unixy thing? Anyway.
Goto http://www.php.net and downloads and get the version of PHP 4.0.5 thats 5 megs large. Windows Binaries of course. This has GD ready compiled as a DLL. You will need to alter the php.ini file to make em work tho. If you need more help mail me.
Thanks for your responding.
I have downloaded and installed PHP 4.0.5 as you suggested. Besides, I have altered the php.ini file and uncommented php_gd.dll as well. In addition, I have used phpinfo (); command to see php variables and found that JPEG, PNG, WBMP support was emabled. But, after creating an image using image generation commands of php, I have tried to run the script on my browser but instead of image I found strange characters all over my browser screen. I do not understand what went wrong. Under the circumstances, could you help me any further please.
Regards.
Ziaur Rahman
sounds like something to do with the way the server handles it but beyond this im not very good.
im only a newbie. sorry my freind.
If you are getting wierd characters all over the screen, it could be because you have additional header information before the image creation process. For generating an image with gd in php, make sure that you only code in the commands for creating the image, and nothing else before it.
If you want to add it into a page with other content, insert it as an image (ex. <img src='show_image.php'> ) and that should work.
Thanks for your help.
I tried to creat image using the following php commands:
<?php
Header("Content-type: image/jpeg");
$im = @ImageCreate (50, 100)
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);
?>
I even tried to create image without the “Header("Content-type: image/jpeg");” but it did not work either.
I also tried to insert it to a page as image (ex. <img src='show_image.php'> ) as you suggested but nothing worked.
Could you please explain the GD matter of windows elaborately?
Regards
Zia
When you say that it did not work, what exactly happens? Do you get an error message, or just a blank screen, or wierd crazy text, or a broken picture image (or something else?)
To be honest, I can't really give you an elaborate explanation of how the GD library works, all I know is how I got it to work. That is, downloading the dll (php_gd.dll) into the extensions director and enabling it in the php.ini file.
If you're just getting frustrated, you can try re-installing PHP with EasyWindows. This is a setup that come pre-packaged with the GD library all set up for you for windows. This also has the bonus of coming with a version that can use the GIF format (the new ones can't). You can get the EasyWindows installer at http://php.weblogs.com/easywindows
kiwi_uk
05-29-2001, 07:39 AM
ive gotta say i altered the code a bit but it works absolutly fabulously for me my freind. I'm using PHP 4.0.5, Xitami (web serveR) and windows 98.
My Code:
<?php
Header("Content-type: image/jpeg");
$im = @ImageCreate (200, 20)
or die ("Cannot Initialize new GD image stream");
$background_color = ImageColorAllocate ($im, 255, 255, 255);
$text_color = ImageColorAllocate ($im, 233, 14, 91);
ImageString ($im, 20, 5, 5, "A Simple Text String", $text_color);
ImageJPEG ($im);
ImageDestroy($im);
?>
I am also using PHP4.0.5 on windows98 with OmniHTTPD v2.08.
Has it anything to do with Web server? If I install PWD sever, do you think I the problem will be solved?
No. PWS Sucks. Get Xitami or BadBlue both of which work fine for me when creating imaghes with GD.
Now I have installed Xitamy v2.3c3 and used with PHP 4.0.5 but the problem remained the same. Although, everything seemed working fine except IMAGE GREATETION.
Following configuration shows the DG support was enabled. I don’t understand what went wrong. Could you help me any further?
Gd
GD Support enabled
GD Version 1.6.2 or higher
FreeType Support enabled
FreeType Linkage with TTF library
JPG Support enabled
PNG Support enabled
WBMP Support enabled
kiwi_uk
05-30-2001, 09:14 AM
I have been experimenting with code. When I mix output (HTNML and Images) it wont work - i just get rubbish text. The only way I could make it work was have the image creation code in one file (imgcode.php) and then do it like this::
<head>
<title>GD Test Page</title>
</head>
<body>
<img src="imgcode.php">
<p>Your image above</p>
</body>
and it works fine. Im not sure why you get rubbsih text instead of the image but i think it is a headers issue. If that way works I cant see any drawbacks. Good luck.
PS> Why do you want to use GD. What for?
I am using the GD library to generate buttons with dynamic use of ImageTTFText for the link name. (left end, changable text on top of resized 1px wide image, right end)
I've got my code to work but wth one major problem, the images being created seem to be using a windows color palette. This is making my nice gradient fills look terrible. Is there anyway of increasing the colors used to above 256 or change to an adaptive palette.
The MAJOR drawback I have here is the server I am hosting from is only using gd version 1.6 or above, so I cant use CreateTrueColorImage. I have requested an upgrade but no answer yet.
I don't want to alter the images code each time i want to create a button with different base images, as I will be allowing users to upload their button images to my site.
PHP Builder
Copyright WebMediaBrands Inc. All Rights Reserved.