PDA

View Full Version : gd lib problem


usban
10-23-2002, 03:22 PM
I'm having a lot of problems while i'm triyng to draw some graphics on my web page.

I have the zlib, the b2zlib and the gd library installed in my computer and i have activated the three llibraries in my php.ini, but when i try to use it it fails and i get the red cross instead of the picture.

The program is here:

http://www.zend.com/zend/tut/statistics.php


It is for building graphical statistics on the fly but it doesn't work

kii
10-24-2002, 08:12 PM
Have you tried a very basic GD image output script? Are you sure the problem is in the GD part or might it be in the access-log reading part?

<?php
header ("Content-type: image/jpeg");
$tt = imagecreate(50,50);
ImageColorAllocate($tt,128,128,255);
ImageJPEG($tt);
ImageDestroy($tt);
?>

If that produces a light blue square when surfed to, GD works.

usban
10-25-2002, 11:48 AM
I get something very strange, i don't if it is becuase i do it bad or because the library is not well isntalled or what's this.

I have copied exactly the above function.

Sorry for the incovenience of this strange characters but as they said something maybe somenone know what they mean


Warning: Cannot add header information - headers already sent by (output started at c:\inetpub\wwwroot\Pruebas de PHP\ODBC\Tipos\cuadrado.php:8) in c:\inetpub\wwwroot\Pruebas de PHP\ODBC\Tipos\cuadrado.php on line 9

JFIF>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality C    $.' ",#(7),01444'9=82<.342C  2!!2222222222222222222222222222222222222222222222222222" ĵ}!1AQa"q2#BR$3br %&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz  ĵw!1AQaq"2B #3Rbr $4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz ?EWEPEPEPEPEPEPEPEPEPEPEPEPEPEPEP

kii
10-25-2002, 12:00 PM
You were NOT meant to include that in another page - it was a standalone script.

Unless you are constructing your output as an object, you cannot use any header calls after anything is sent to the browser (eg <html> ), so if the page has been started and maybe has <html><body><table... etc, NO additional headers can be added. Generally you'd get round that for GD creations by referencing the script as a src attribute of an img tag - <img src="script.php" />

usban
10-25-2002, 12:11 PM
I get the square if i comment the last line of the script


<?php
header ("Content-type: image/jpeg");
$tt = imagecreate(50,50);
ImageColorAllocate($tt,128,128,255);
ImageJPEG($tt);
//ImageDestroy($tt);
?>


So the Gd.library is working properly and the porblem is in another point, isn't it??

kii
10-25-2002, 05:15 PM
I would suspect so, yes.

Having to comment out the ImageDestroy call is very strange though and to be honest I have no idea why you would need to.

Are you using a GD version above 2 by any chance?
I've heard that the memory leaks apparent in earlier versions have been sorted, which (and I'm just guessing here) might also have spurred them into combining the ImageDestroy functionality into the ImageJPEG/PNG function (which imo would make sense).

As you cannot easily debug an <img src="script.php" /> GD script, I would suggest trying to echo the passed variables to page as their values. Then possibly try hardcoding a var=vals src call.
Eg - if the img tag has src="script.php?a='.$set_a.'&b='.$set_b.'", you would remove the tag totally and just echo $set_a.'--'.$set_b;, followed perhaps by just trying <img src="script.php?a=33&b=77" />
Should hopefully give you an idea of where the problem lies anyway.