PHP Code:
<?php
$width = (isset($_GET['width']) ? $_GET['width'] : 403);
$height = (isset($_GET['height']) ? $_GET['height'] : 30);
$text = $_GET['text'];
if ($text == "") {$text="The quick brown fox jumped over the lazy dog.";}
list($tcr, $tcg, $tcb) = array(0,0,0);
list($gctr, $gctg, $gctb) = array(255,0,0);
list($gcbr, $gcimg, $gcbb) = array(0,255,255);
$img = imagecreatetruecolor($width,$height);
for($y=0;$y<$height;$y++) {
$percent = (($y+1)/$height);
$r = ($percent*$gctr)+((1-$percent)*$gcbr);
$g = ($percent*$gctg)+((1-$percent)*$gcimg);
$b = ($percent*$gctb)+((1-$percent)*$gcbb);
$rowpxcolor = imagecolorallocate($img, $r, $g, $b);
for ($x=0;$x<$width;$x++) {
imagesetpixel($img, $x, $y, $rowpxcolor);
}
}
function flipimage($image) {
global $width;
global $height;
$image2 = imagecreatetruecolor($width,$height);
for($y=0;$y<$height;$y++) {
for ($x=0;$x<$width;$x++) {
imagesetpixel($image2, $x, ($height-$y), imagecolorat($image,$x,$y));
}
}
return $image2;
}
$textcolor = imagecolorallocate($img, $tcr, $tcg, $tcb);
imagestring($img, 5, 0, 0, $text, $textcolor);
$img = flipimage($img);
imagestring($img, 5, 0, 0, $text, $textcolor);
$img = flipimage($img);
header('Content-Type: image/jpeg');
imagejpeg($img,"","95%");
imagedestroy($img);
?>
The problem at this point is that the text isn't centered, vertically or horizontally. It's possible, but I'd need to based that on the width of the text generated, so I guess I'd need to render the text to test out how wide it becomes.
Bookmarks