This is a discussion on GD2 Producing Empty Images within the PHP Language forums, part of the PHP Programming Forums category; I've found a problem with many of my PHP installations. I'm not sure whether it's a PHP ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
I've found a problem with many of my PHP installations. I'm not sure
whether it's a PHP problem, or an Apache problem, or something else again. The issue appears when we try to use the following snippet from the PHP docs for imagecreate(): <?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); imagepng($im); imagedestroy($im); ?> This brings up an empty page. FF Page Info shows a 0px x 0px png. I'm using Win2K on 2 of my 3 machines. On the 3rd, XP machine I'm using xampp which uses Apache 2, and it works on that one. Currently trying to install xampp on my main workstation (win2k), but can't get existing port 80 server cleared... That's another issue. Anyone have similar problems with GD2 in PHP? Thanks, - AAA |
|
|||
|
alfred.ayache@gmail.com wrote:
> I've found a problem with many of my PHP installations. I'm not sure > whether it's a PHP problem, or an Apache problem, or something else > again. > > The issue appears when we try to use the following snippet from the > PHP docs for imagecreate(): > > <?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); > imagepng($im); > imagedestroy($im); >> > > This brings up an empty page. FF Page Info shows a 0px x 0px png. > I'm using Win2K on 2 of my 3 machines. On the 3rd, XP machine I'm > using xampp which uses Apache 2, and it works on that one. What if you move the header bit, and try to view the php file directly? Sending a header before any errors may be outputted can screw up your possibility to see the errors. <?php $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) or die('Cannot create text'); header("Content-type: image/png"); imagepng($im); imagedestroy($im); ?> It works here BTW, without problems. Could you maybe give us the GD bit's of phpinfo() from the different servers? (here: GD Support enabled GD Version bundled (2.0.28 compatible) FreeType Support enabled FreeType Linkage with freetype FreeType Version 2.1.9 T1Lib Support enabled GIF Read Support enabled GIF Create Support enabled JPG Support enabled PNG Support enabled WBMP Support enabled XBM Support enabled) Grtz, -- Rik Wasmus |
|
|||
|
alfred.ayache@gmail.com wrote:
> > I've found a problem with many of my PHP installations. I'm not sure > whether it's a PHP problem, or an Apache problem, or something else > again. > > The issue appears when we try to use the following snippet from the PHP > docs for imagecreate(): Since you are using a code snippet from the docs I simply assume it is correct without checking it. Which brings me to one of the standard errors when using the GD2 library: Have you made sure you enabled it? It is disabled in a standard PHP install. Look into the php.ini file, look for the line extension=php_gd2.dll and if the line looks like this ;extension=php_gd2.dll remove the ; in front of it, then restart Apache. |