Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 8th, 2006, 05:15 PM
alfred.ayache@gmail.com
Guest
 
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

  #2  
Old August 8th, 2006, 05:35 PM
Rik
Guest
 
Posts: n/a
Default Re: GD2 Producing Empty Images

alfred.ayache@gmail.com wrote:
Quote:
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);
Quote:
>>
>
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


  #3  
Old August 8th, 2006, 07:05 PM
Anonymous
Guest
 
Posts: n/a
Default Re: GD2 Producing Empty Images

alfred.ayache@gmail.com wrote:
Quote:
>
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.
 

Bookmarks

Thread Tools

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

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles