I am trying to use the gd libraries to create a basic image but am having some problems. I am using apache/1.3.22 with PHP/4.0.6. I have uncommented the php_gd.dll extension in the php.ini file and restarted apache. To ensure that gd was compiled I used the phpinfo() function to check. Gd is now enabled.

I am using the following code to create the image:


Header("Content-Type image/png");
$im = ImageCreate(500, 75);
$red = ImageColorAllocate($im, 255,0,0);
ImageFill($im, 100, 100, $red);


The first problem that I noticed is that the ImagePNG()funtion is not highlighted in the editor.

When I run the script the following warning is dislayed:

Warning: Cannot add header information - header already sent by(output started at c:\program files\apache\group\apache\htdocs\test6.php:2) in C:\program files\apache group\apache\htdocs\test6.php on line 4

Looking at this I think that the header has already been included. So I commented out the Header() function. This removed the warning but still the image was not displayed, only garbage text.

I have spent some time looking for a solution to this problem but have had no luck. Any help on this topic would be gratefully appreciated.

Thanks in advance