images
| From: | Jon Yaggie | Date: | Sat, 26 May 2001 20:01:34 +0000 |
| Subject: | images | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-55280@lists.php.net to get a copy of this message | ||
I am trying to produce buttons with imagecreatefromjpeg(). the problem i am having is i cant
allocate a color for the text of the betton. it appears i have 2 choices black and gray. Anyone
know why this could be. Code is below
<?php Header("Content-Type: image/jpeg");
switch($buttontype)
{
case 1:
$buttonfile = "images/button1.jpg";
break;
case 2:
$buttonfile = "images/button2.jpg";
break;
}
$im = imagecreatefromjpeg($buttonfile);
switch($color)
{
case 1:
$imcolor = imagecolorallocate($im, 255, 0, 0);
break;
case 2:
$imcolor = imagecolorallocate($im, 0, 255, 0);
break;
case 3:
$imcolor = imagecolorallocate($im, 0, 0, 255);
break;
}
$sizex = imagesx($im);
$sizey = imagesy($im);
$fontlen = imagefontwidth(3);
$strlen = strlen($text) * $fontlen;
$xvalue = ($sizex - $strlen)/2;
$yvalue = $sizey * .40;
imagestring($im, 3, $xvalue, $yvalue, $text, $o);
imagejpeg($im);
?>
Thank You,
Jon Yaggie
www.design-monster.com
And they were singing . . .
'100 little bugs in the code
100 bugs in the code
fix one bug, compile it again
101 little bugs in the code
101 little bugs in the code . . .'
And it continued until they reached 0