I had a project in which I had to generate an image based on a string. The problem was that the text had to be displayed circulary. After hours of internet searching I’ve came across http://www.phpgd.com and found this piece of code which did the job quite nicely.

<?php

$text = “Around and around around and around and around “;

$image = imagecreatetruecolor(400,400);
$white = imagecolorallocate($image,255,255,255);
imagefill($image,0,0,$white);
$red = imagecolorallocate($image,255,0,0);

$degrees = (360/strlen($text));

for ($i=0;$i<strlen($text);$i++) {

$a = ($degrees*$i)+180;

$cos = cos(deg2rad($a));
$sin = sin(deg2rad($a));
$x = 0;
$y = 180;
$xt = round($cos*($x) – $sin*($y));
$yt = round($sin*($x) + $cos*($y));
imagettftext($image,20,180-($a),200+$xt,200+$yt,$red,”fonts/arial.ttf”,$text[$i]);

}

header(“Content-type: image/jpeg”);
imagejpeg($image,”",100);
imagedestroy($image);

?>

Here is the direct link to the script http://www.phpgd.com/scripts.php?script=25. You might look through the site because there are other many interesting scripts which may come useful in your projects.

Enjoy!