image gen problems

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
feamsr00
-


Joined: 04 Jun 2002
Posts: 138
Location: Phila PA

PostPosted: Sat Nov 16, 2002 8:45 pm    Post subject: image gen problems Reply with quote

I was going to try image genrating in php so I got this from a tutorial. From what I understand this should work.
The problem is the first time I ran this I got Error 500 then simply refreshing gave me 200 0k. Same after that.

Code:
<?
$ButtonWidth = 100;
$ButtonHeight = 30;
$ButtonLabel = "Testing";
$ButtonFont = 5;
$image = imagecreate($ButtonWidth, $ButtonHeight);
$colorBody = imagecolorallocate($image, 0x99, 0x99, 0x99);
$colorShadow = imagecolorallocate($image, 0x33, 0x33, 0x33);
$colorHighlight = imagecolorallocate($image, 0xCC, 0xCC, 0xCC);
imagefilledrectangle($image, 1, 1, $ButtonWidth-2, $ButtonHeight-2, $colorBody);

//determine label size
$ButtonLabelHeight = imagefontheight($ButtonFont);
$ButtonLabelWidth = imagefontwidth($ButtonFont) * strlen($ButtonLabel);
//determine label upper left corner
$ButtonLabelX = ($ButtonWidth - $ButtonLabelWidth)/2;
$ButtonLabelY = ($ButtonHeight - $ButtonLabelHeight)/2;
//draw label shadow
imagestring($image, $ButtonFont, $ButtonLabelX+1, $ButtonLabelY+1, $ButtonLabel, $colorShadow);
//draw label
imagestring($image, $ButtonFont, $ButtonLabelX, $ButtonLabelY, $ButtonLabel, $colorHighlight);
//output image
header("Content-type: image/png");
imagepng($image);
?>


So, if not making a image, then what is it doing?
Back to top View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Sat Nov 16, 2002 9:58 pm    Post subject: Re: image gen problems Reply with quote

feamsr00 wrote:
I was going to try image genrating in php so I got this from a tutorial. From what I understand this should work.
The problem is the first time I ran this I got Error 500 then simply refreshing gave me 200 0k. Same after that.

Code:
<?
$ButtonWidth = 100;
$ButtonHeight = 30;
$ButtonLabel = "Testing";
$ButtonFont = 5;
$image = imagecreate($ButtonWidth, $ButtonHeight);
$colorBody = imagecolorallocate($image, 0x99, 0x99, 0x99);
$colorShadow = imagecolorallocate($image, 0x33, 0x33, 0x33);
$colorHighlight = imagecolorallocate($image, 0xCC, 0xCC, 0xCC);
imagefilledrectangle($image, 1, 1, $ButtonWidth-2, $ButtonHeight-2, $colorBody);

//determine label size
$ButtonLabelHeight = imagefontheight($ButtonFont);
$ButtonLabelWidth = imagefontwidth($ButtonFont) * strlen($ButtonLabel);
//determine label upper left corner
$ButtonLabelX = ($ButtonWidth - $ButtonLabelWidth)/2;
$ButtonLabelY = ($ButtonHeight - $ButtonLabelHeight)/2;
//draw label shadow
imagestring($image, $ButtonFont, $ButtonLabelX+1, $ButtonLabelY+1, $ButtonLabel, $colorShadow);
//draw label
imagestring($image, $ButtonFont, $ButtonLabelX, $ButtonLabelY, $ButtonLabel, $colorHighlight);
//output image
header("Content-type: image/png");
imagepng($image);
?>


So, if not making a image, then what is it doing?

You should install the php_gd.dll and/or php_gd2.dll as extensions to PHP to allow image creation. These two extensions aren't packaged with the small PHP distribution. You should rather download the 5MB PHP package at http://www.php.net/get_download.php?df=php-4.2.3-Win32.zip and install it in order to have these extensions (and a lot more) by default.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group