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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
loganlinux
Forum Newbie
Posts: 5
Joined: Mon Jul 14, 2003 2:44 am

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

Post 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!)
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

There is no need to triple post - please try and contain yourself with just one thread.

Mac
loganlinux
Forum Newbie
Posts: 5
Joined: Mon Jul 14, 2003 2:44 am

Post by loganlinux »

Sorry, page crashed so I refreshed...didnt realise it sent again! Sorry again!....I still need help tho!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Could we see the code you are using to generate the image?

Mac
loganlinux
Forum Newbie
Posts: 5
Joined: Mon Jul 14, 2003 2:44 am

Sample of PHP GD code

Post 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??
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Have you checked that there are no extra linebreaks after the closing PHP-tag, i.e. "?>"?
loganlinux
Forum Newbie
Posts: 5
Joined: Mon Jul 14, 2003 2:44 am

Sample of PHP GD code

Post 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??
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post 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"?
loganlinux
Forum Newbie
Posts: 5
Joined: Mon Jul 14, 2003 2:44 am

Post 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
Post Reply