Page 1 of 1
using graphics in php
Posted: Sun Nov 10, 2002 6:41 am
by jamal
Hi Guys,
I am trying to check if GD-library is working together with PHP but it failed. I have to run the below code to check it. I have already downloaded GD-1.8.4.
Please can anyone help me on how to configure graphics with php.
Code: Select all
header ("Content-type: image/png");
$im = @ImageCreate ( 50, 100)
or die ("Cannot create a new GD image.");
$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);
thanks
Posted: Sun Nov 10, 2002 8:30 am
by volka
which version of php, which webserver, which OS and failed in what way? (because it's somehow working on my box

)
Posted: Sun Nov 10, 2002 10:03 am
by jamal
php version 4.2.4-dev
apache 1.3.26
win98
The failure is that I did not see the
logo.
Thanks
Posted: Sun Nov 10, 2002 1:44 pm
by volka
try this order
Code: Select all
$im = @ImageCreate ( 50, 100)
or die ("Cannot create a new GD image.");
$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 );
header ("Content-type: image/png");
ImagePng ($im);
so you can see errors because Content-type isn't altered until the last statement. And take a look into server's error.log
Posted: Sun Nov 10, 2002 4:15 pm
by jamal
I tried the code above but unfortunately I saw nothing. The page was blank.
Can you help me any futher. I checked the phpinfo to see if the gd was installed. I did not see it there. I am going crazy. I am interested in this concept. Can anybody help me anybody before I die?
Thanks
Posted: Sun Nov 10, 2002 6:56 pm
by volka
the output of
should contain a section simliar to
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
if not you have to add the php-gd extension.
- In your php/extensions-directory there are two libs
- php_gd.dll
- php_gd2.dll
- check your php.ini settings
- extension_dir should point to your php/extensions-dir (e.g. mine is extension_dir = c:/programme/php423/extensions)
- uncomment one extension-entry, either extension=php_gd.dll or extension=php_gd2.dll
Posted: Mon Nov 11, 2002 3:29 am
by twigletmac
If you used the PHP installer to install PHP then you won't have the extensions folder with all the nice useful extensions in it - you'll need the PHP zip package to get them.
http://www.php.net/downloads.php
Mac
using graphics in php
Posted: Mon Nov 11, 2002 11:29 am
by jamal
Yes I have reinstalled the php-4.2.3-win32 from the start again. I could see that it contained all the dlls. But I thought I have to install the gd at this site
http://www.boutell.com/gd/manual1.8.4.html#whatis
before i can have it working??
Are these( gd, libpng, t1lib, freetype, and jpeg ) installed by default. The dlls are in the php in which I installed.
Thank you for sparing your time to assist me.
Jamal
Posted: Mon Nov 11, 2002 3:50 pm
by volka
the
php_XYZ.dlls from the win32-zip-package are all you need, but you have to include these extensions in the php.ini
they are not loaded by default.
change
to
to enable the extension.