GD2 Producing Empty Images

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 ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-08-2006
alfred.ayache@gmail.com
 
Posts: n/a
Default GD2 Producing Empty Images

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

Reply With Quote
  #2 (permalink)  
Old 08-08-2006
Rik
 
Posts: n/a
Default Re: GD2 Producing Empty Images

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


Reply With Quote
  #3 (permalink)  
Old 08-08-2006
Anonymous
 
Posts: n/a
Default Re: GD2 Producing Empty Images

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.
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 12:09 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0