I hava jpg from which i am trying to create a button. I pass three variables to it. color of text, buttonstyle, and actual text to be placed on the button. problem is that it seems to not want to add colors. so if the color doesnt already exist in the image it simply will not use this color. Why is this? can i some how change this?
The code -
<?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;
}
imagefill($im, 5, 5, $white);
$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, $imcolor);
imagejpeg($im);