What I have so far is:
<?php
$ext="png";
$headerinfo="Content-type: image/png";
//Content-type: image/jpeg
if (!isset($s)){$s=1;}else{if ($s<1){$s=1;}if ($s>5){$s=5;}}
if (!isset($c)) {$c="b";}
if (file_exists("./cj/$t-$s-$c.$ext"))
{
header("$headerinfo");
$fn=fopen("./cj/$t-$s-$c.$ext","r");
fpassthru($fn);
}
else
{
header("$headerinfo");
$tl=strlen($t);
//image width
//$iw=$tl*5+4;
$iw=($tl*(4+$s))+4;
//image height
$ih=((3*$s)+7);
$im = @imagecreate($iw, $ih)
or die("Cannot Initialize new GD image stream");
$background_color = imagecolorallocate($im, 255, 255, 255);
$blackcolor=imagecolorallocate($im, 0, 0, 0);
$bluecolor=imagecolorallocate($im, 1, 1, 155);
$yellowcolor=imagecolorallocate($im, 255, 255, 0);
$redcolor = imagecolorallocate($im, 233, 14, 91);
if ($c=="b") {$text_color=$bluecolor;}
if ($c=="k") {$text_color=$blackcolor;}
if ($c=="y") {$text_color=$yellowcolor;}
if ($c=="r") {$text_color=$redcolor;}
imagestring($im, $s, 1, 1, $t, $text_color);
//imagepng($im);
//imagepng($im,"./$t.png");
//imagejpeg($im);
imagejpeg($im,"./cj/$t-$s-$c.$ext");
$fn=fopen("./cj/$t-$s-$c.$ext","r");
fpassthru($fn);
imagedestroy($im);
}
?>
It works wonderfully for what it was originally designed but I know it could probably be much better...
I just call it with img src=di.php?t=text&c=b&s=1
t=text obviously, c=color and s=size. I want to add w for width.
Any ideas how to modify it to do word wrapping and width? I know it would probably be breaking down all the words individually, counting them one by one, dividing them into wordwrappable sized lines... then counting the height and calling the image width and height accordingly...