jonnyw6969 Posted December 8, 2010 Share Posted December 8, 2010 Hi Guys, Some help here would be most appreciated. What im basically trying to do is create an image like a postmark stamp where the text curves around the inside of the circle. This text is dynamically generated and will basically be a persons name. So I need a circle with the persons name curving inside the circle edge at the top. I have attached a image of a postmark just incase anyone isnt sure what i mean. [/img] If anyone could help it would be great. Regards, Jon [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/221044-need-to-write-text-in-a-circle/ Share on other sites More sharing options...
micha8l Posted December 8, 2010 Share Posted December 8, 2010 I believe this could help you: http://www.boutell.com/gd/ Quote Link to comment https://forums.phpfreaks.com/topic/221044-need-to-write-text-in-a-circle/#findComment-1144549 Share on other sites More sharing options...
litebearer Posted December 8, 2010 Share Posted December 8, 2010 more specifically - http://www.ithowto.ro/2009/03/howto-write-circular-text-with-php-and-gd/ Quote Link to comment https://forums.phpfreaks.com/topic/221044-need-to-write-text-in-a-circle/#findComment-1144597 Share on other sites More sharing options...
QuickOldCar Posted December 9, 2010 Share Posted December 9, 2010 Those codes don't work, try them. But the one below does, replace the font with your own font and location. <?php $text = "- Phpfreaks - QuickOldCar"; $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,"font.TTF",$text[$i]); } header("Content-type: image/jpeg"); imagejpeg($image,"",100); imagedestroy($image); ?> Quote Link to comment https://forums.phpfreaks.com/topic/221044-need-to-write-text-in-a-circle/#findComment-1144754 Share on other sites More sharing options...
QuickOldCar Posted December 9, 2010 Share Posted December 9, 2010 If you want just a name with arc on top change the $degrees and then the $a values for length of your text to look right. <?php $text = "QuickOldCar"; $image = imagecreatetruecolor(400,400); $white = imagecolorallocate($image,255,255,255); imagefill($image,0,0,$white); $red = imagecolorallocate($image,255,0,0); $degrees = (180/strlen($text)); for ($i=0;$i<strlen($text);$i++) { $a = ($degrees*$i)+95; $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,"font.TTF",$text[$i]); } header("Content-type: image/jpeg"); imagejpeg($image,"",100); imagedestroy($image); ?> Quote Link to comment https://forums.phpfreaks.com/topic/221044-need-to-write-text-in-a-circle/#findComment-1144758 Share on other sites More sharing options...
QuickOldCar Posted December 9, 2010 Share Posted December 9, 2010 I didn't notice you said within a circle also, so here is for that. <?php $text = "QuickOldCar"; $image = imagecreatetruecolor(400,400); $white = imagecolorallocate($image,255,255,255); imagefill($image,0,0,$white); $red = imagecolorallocate($image,255,0,0); $degrees = (180/strlen($text)); $black = imagecolorallocate($image, 0, 0, 0); imagearc($image, 200, 200, 390, 390, 0, 360, $black); for ($i=0;$i<strlen($text);$i++) { $a = ($degrees*$i)+95; $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,12,180-($a),200+$xt,200+$yt,$red,"font.TTF",$text[$i]); } header("Content-type: image/jpeg"); imagejpeg($image,"",80); imagedestroy($image); ?> Quote Link to comment https://forums.phpfreaks.com/topic/221044-need-to-write-text-in-a-circle/#findComment-1144761 Share on other sites More sharing options...
jonnyw6969 Posted December 9, 2010 Author Share Posted December 9, 2010 thanks guys that is amazing. I cant beleive how quickly you got back to me and what great answers you gave. My problem is solved and i cant thank you enough. JW Quote Link to comment https://forums.phpfreaks.com/topic/221044-need-to-write-text-in-a-circle/#findComment-1144900 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.