Jump to content

GD2 Installed but won't work


serblowa

Recommended Posts

Hello,

 

I'm fairly new to PHP, and I'm trying to get the GD2 library working but I am having no luck. I have installed the library, and when I run phpinfo(); it shows that it is up and running, and all file types are supported. However, when I run the following code snippet nothing is displayed:

 

<?php

  $im = @imagecreate (200, 100) or die ( "cannot create a new gd image.");

  $background_color = imagecolorallocate ($im, 240, 240, 240);

  $border_color = imagecolorallocate ($im, 50, 50, 50);

  $text_color = imagecolorallocate ($im, 233, 14, 91);

  imagerectangle($im,0,0,199,99,$border_color);

  imagestring ($im, 5, 10, 40, "a simple text string", $text_color );

  header ("content-type: image/png");

  imagepng ($im);

?>

 

I have been struggling with this for a couple of weeks now with no luck. Any help would be greatly appreciated.

Link to comment
Share on other sites

Well I enabled error logging and removed the @ sign, but still no luck. I entered some obviously wrong code and the error logger did show an error. However, I'm not seeing any errors when I execute the code segment above. I tried opening the script in several browsers, and I did find that Firefox threw the following error:

 

Error: Image corrupt or truncated: http://192.168.0.176/simplegraph

Source File: http://192.168.0.176/simplegraph

Line: 0

 

 

Link to comment
Share on other sites

So still no luck. I have tried some sample code online that appears to work. I have tried calling my php script from an html file and I still can't get any kind of image to display. So I am wondering if there is a minimum system requirement to get GD2 to work properly. I am using an old computer (Celeron 2Ghz with 256MB of RAM), and I am wondering if GD2 just needs more resources. I tried looking for some documentation on this and found nothing.

 

Does anyone know if this could possibly be the problem?

Link to comment
Share on other sites

Temporarily comment out the header(... ...); line of code and browse directly to the url of the .php file (i.e. don't use an <img src='' tag in a html page.)

 

The URL you posted doesn't have any extension. Are you using some url rewriting that perhaps doesn't work? Does any .php code work on your localhost system?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.