logo
Apache Lounge
Webmasters

 


About

Forum Index Downloads Search Register Log in  RSS Apache Lounge
 



Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Apache Lounge is not sponsored.

Your donations will help to keep this site alive and well, and continuing building binaries.



PHP5 and GD

 
Post new topic   Reply to topic    Apache Forum Index -> Coding & Scripting Corner



View previous topic :: View next topic  
Author Message
x24804



Joined: 22 Nov 2006
Posts: 2

PostPosted: Tue 05 Dec '06 20:50    Post subject: PHP5 and GD Reply with quote

Hi All,

I'm having an issue with using GD in my PHP script. Following is the script:

**************************
<?php
// set up image
$height = 200;
$width = 200;
$im = imagecreate($width, $height);
$white = imagecolorallocate($im, 255, 255, 255);
$blue = imagecolorallocate($im, 0, 0, 64);

//draw on image
imagefill($im, 0, 0, $blue);
imageline($im, 0, 0, $width, $height, $white);
imagestring($im, 4, 50, 150, 'Sales', $white);

//output image
header('Content-type: image/png');
imagepng($im);

//clean-up
imagedestroy($im);
?>

**************************

All of this is within the "body" tags. When I run this (through Dreamweaver) I get the following displayed on the screen:

"The image “http://localhost/simplegraph.php” cannot be displayed, because it contains errors."

What errors are there? I checked the phpinfo(); script, and it DOES show that I have gd enabled. I looked at my Apache error logs and I don't see anything telling me about THIS error. I tried other sample codes and I get the exact same error message. What could I possibly be doing wrong? Do I need that mcimage software? Of note, I noticed that I'm NOT able to write, for example, "ImageCreateTrueColor" as is...I must write all of the commands in small caps (imagecreatetruecolor). Could that be a sign of trouble? (I'm using Windows XP Professional...yes, I know, and I'll be moving to the Mac OS in a few months.) Thanks.

Telly
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 6255
Location: Germany, Next to Hamburg

PostPosted: Wed 06 Dec '06 10:28    Post subject: Reply with quote

This can not work in <body></body> You have to include it as an image.

Code:

...
<body>
....

<img src="your.php" with="200" height="200" alt="your text" border="0" />

...
</body>
Back to top
x24804



Joined: 22 Nov 2006
Posts: 2

PostPosted: Thu 07 Dec '06 3:39    Post subject: No dice Reply with quote

James,

That doesn't work either. The funny thing is that I downloaded GDGraph from Hotscripts and THAT works just fine. I tried every code you posted including the one from the PHP site. Thanks, though.

Telly
Back to top
Brian



Joined: 21 Oct 2005
Posts: 209
Location: Puyallup, WA USA

PostPosted: Sat 09 Dec '06 0:26    Post subject: Reply with quote

Do you have a PHP.LOG file you could refer to?

Check that and the server logs as well as even maybe the Windows event viewer (I am grasping on that one).

Finally, did you kick out the preceeding header such as:
Code:
header( 'content-type: image/pjpeg' );
header( 'content-type: image/gif');
... and so on...


This would be done within the image generating script, so if your script does not tell the browser what to expect, then it wont necessarily know how or what to display.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 6255
Location: Germany, Next to Hamburg

PostPosted: Sat 09 Dec '06 9:45    Post subject: Reply with quote

I tested that script on my server and it works fine.
Back to top


Post new topic   Reply to topic    Apache Forum Index -> Coding & Scripting Corner
Page 1 of 1