No Luck getting Graphics to display
Posted: Tue Jan 15, 2008 12:42 pm
Hello all,
I am trying to use simple GD functions to accomplish any mundane task such as creating and displaying a rectangle and have had no success. In IE 6, the following code fails continually with "Cannot Create White" when trying to create the white color. In Firefox, it will fail at the same place if the header line is removed, otherwise it gives me the error :"The image “http://localhost/index.php” cannot be displayed, because it contains errors." I am at my wits end here and have been trying to resolve this problem for a number of hours. I have tried upgrading the PHP_GD2.dll file alone, downloading the newest version of php, and messing with all sorts of browser settings and php.ini settings.
I am trying to use simple GD functions to accomplish any mundane task such as creating and displaying a rectangle and have had no success. In IE 6, the following code fails continually with "Cannot Create White" when trying to create the white color. In Firefox, it will fail at the same place if the header line is removed, otherwise it gives me the error :"The image “http://localhost/index.php” cannot be displayed, because it contains errors." I am at my wits end here and have been trying to resolve this problem for a number of hours. I have tried upgrading the PHP_GD2.dll file alone, downloading the newest version of php, and messing with all sorts of browser settings and php.ini settings.
Code: Select all
<?php
header('Content-Type: image/png');
$im = ImageCreate(200,200) or die ("Cannot Create Image");
$white = ImageColorAllocate($im,255,255,255) or die ("Cannot Create White");
$black = ImageColorAllocate($im,0,0,0) or die ("Cannot Create Black");
ImageFilledRectangle($im, 50, 50, 150, 150, $black) or die ("Cannot Fill Rectangle");
ImagePNG($im);
?>