Page 1 of 1

Newbie question: GD and PHP all looks good but no images!!

Posted: Mon Jul 14, 2003 2:44 am
by loganlinux
Hi friends,

I have everything installed to get graphs from php (ie gdlib etc) but it doesnt seem to be working.

I hope this screenshot comes through...Im trying to get a simple png from php 4.2.2 but its not working (sadly i am using redhat 9 -shrike)

PLEASE HELP!

gd is enabled from the PHP settings/config!! (screenshot didnt work!)

Posted: Mon Jul 14, 2003 3:54 am
by twigletmac
There is no need to triple post - please try and contain yourself with just one thread.

Mac

Posted: Mon Jul 14, 2003 7:06 am
by loganlinux
Sorry, page crashed so I refreshed...didnt realise it sent again! Sorry again!....I still need help tho!

Posted: Mon Jul 14, 2003 7:41 am
by twigletmac
Could we see the code you are using to generate the image?

Mac

Sample of PHP GD code

Posted: Mon Jul 14, 2003 6:45 pm
by loganlinux
Hi, thanks for the reply!

Simple -
<?php
Header("Content-type: image/gif");
$string=implode($argv," ");
$im = imagecreatefromgif("images/button1.gif");
$orange = ImageColorAllocate($im, 220, 210, 60);
$px = (imagesx($im)-7.5*strlen($string))/2;
ImageString($im,3,$px,9,$string,$orange);
ImageGif($im);
ImageDestroy($im);
?>
and a phpinfo() query returns that php4.2.2 is installed and --with gd and all the font types are included in the configuration. Dont know if this means it should work??

Posted: Mon Jul 14, 2003 7:36 pm
by patrikG
Have you checked that there are no extra linebreaks after the closing PHP-tag, i.e. "?>"?

Sample of PHP GD code

Posted: Mon Jul 14, 2003 7:40 pm
by loganlinux
Hi, thanks for the reply!

Simple -
<?php
Header("Content-type: image/gif");
$string=implode($argv," ");
$im = imagecreatefromgif("images/button1.gif");
$orange = ImageColorAllocate($im, 220, 210, 60);
$px = (imagesx($im)-7.5*strlen($string))/2;
ImageString($im,3,$px,9,$string,$orange);
ImageGif($im);
ImageDestroy($im);
?>
and a phpinfo() query returns that php4.2.2 is installed and --with gd and all the font types are included in the configuration. Dont know if this means it should work??

Posted: Mon Jul 14, 2003 7:45 pm
by patrikG
The code looks suspiciously like the code you posted above (hint: use the [ php] ... [/ php] tags when you post code). ;)

I take that as a "no, there are no extra-linebreaks"?

Posted: Mon Jul 14, 2003 8:27 pm
by loganlinux
Thanks patrick,

No, it seems there is no extra line breaks

Here is another "simpler" example that I am trying to get working...

This actually gives no error and displays nothing on the page!

php tag
header("Content-type = image/png");
$im = imagecreate (300, 300);
$white = imagecolorallocate ($im,255,255,255);
$blue = imagecolorallocate ($im,0,0,255);
close php tage

then the second part in the saem file
open php tag
imagestring ($im, 5, 0, 0 "I need this to work!", $blue);
close tag