bobinindia Posted March 1, 2008 Share Posted March 1, 2008 Is it possible to generate arced text. I can keep the arc constant but need to able to change the text. Any chance? ??? Link to comment https://forums.phpfreaks.com/topic/93815-trying-to-arc-text-on-an-image-layer-gd-liibrary/ Share on other sites More sharing options...
trq Posted March 1, 2008 Share Posted March 1, 2008 In what? html? Link to comment https://forums.phpfreaks.com/topic/93815-trying-to-arc-text-on-an-image-layer-gd-liibrary/#findComment-480737 Share on other sites More sharing options...
bobinindia Posted March 1, 2008 Author Share Posted March 1, 2008 yes it will then generate an html page Link to comment https://forums.phpfreaks.com/topic/93815-trying-to-arc-text-on-an-image-layer-gd-liibrary/#findComment-480739 Share on other sites More sharing options...
trq Posted March 1, 2008 Share Posted March 1, 2008 Can't be done in html Im afraid. Link to comment https://forums.phpfreaks.com/topic/93815-trying-to-arc-text-on-an-image-layer-gd-liibrary/#findComment-480741 Share on other sites More sharing options...
bobinindia Posted March 1, 2008 Author Share Posted March 1, 2008 but can it be done sever side and then create an image which then be displayed like any other image? Link to comment https://forums.phpfreaks.com/topic/93815-trying-to-arc-text-on-an-image-layer-gd-liibrary/#findComment-480743 Share on other sites More sharing options...
trq Posted March 1, 2008 Share Posted March 1, 2008 Can't see why you couldn't do it with imagearc, Ive never tried it though so couldn't really help. Link to comment https://forums.phpfreaks.com/topic/93815-trying-to-arc-text-on-an-image-layer-gd-liibrary/#findComment-480748 Share on other sites More sharing options...
bobinindia Posted March 1, 2008 Author Share Posted March 1, 2008 Thanks for your help. I am experimenting!?! :-\ Link to comment https://forums.phpfreaks.com/topic/93815-trying-to-arc-text-on-an-image-layer-gd-liibrary/#findComment-480773 Share on other sites More sharing options...
bobinindia Posted March 1, 2008 Author Share Posted March 1, 2008 So here is the code. I want to imagerotate() each character from imagechar() before it is printed. Any suggestions? <?php $string = '1 2 3 4 5 6 7 8 9 A B C D E F G'; $font_size = 5; $width=imagefontwidth($font_size)*strlen($string); $height=imagefontheight($font_size)*2; $img = imagecreate($width,$height); $bg = imagecolorallocate($img,225,225,225); $black = imagecolorallocate($img,0,0,0); $len=strlen($string); $r = 100; for($i=0;$i<$len;$i++) { $xpos=$i*imagefontwidth($font_size); $ypos=6; //somehow rotate in here below imagechar($img,$font_size,$xpos,$ypos,$string,$black); $string = substr($string,1); } header("Content-Type: image/gif"); imagegif($img); imagedestroy($img); ?> Link to comment https://forums.phpfreaks.com/topic/93815-trying-to-arc-text-on-an-image-layer-gd-liibrary/#findComment-480783 Share on other sites More sharing options...
helraizer Posted March 1, 2008 Share Posted March 1, 2008 Umm.. I think you'll have to improvise on this one. There is no easy way to create arced text as a whole, as such that I know of.. But with imagettftext: imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text ) the third element is float angle, which you can set to face the character facing from 0 to 359 degrees. If you have $string, you can use $str_split($string, 1) to split the string up into one character chunks. Then use imagettftext for all of them, using a slightly different angle for each and a slightly different x and y co-ord. Will give an arced effect, with experimenting. Hope that helps? Sam Link to comment https://forums.phpfreaks.com/topic/93815-trying-to-arc-text-on-an-image-layer-gd-liibrary/#findComment-480806 Share on other sites More sharing options...
Barand Posted March 1, 2008 Share Posted March 1, 2008 In the FAQ/code snippets http://www.phpfreaks.com/forums/index.php/topic,147174.0.html Link to comment https://forums.phpfreaks.com/topic/93815-trying-to-arc-text-on-an-image-layer-gd-liibrary/#findComment-480810 Share on other sites More sharing options...
bobinindia Posted March 1, 2008 Author Share Posted March 1, 2008 So here is the solution as it must be shared. Thank you all for your suggestions. <?php //This works with GD2 and PHP 5. $text = "SAI BABA SAI BABA SAI BABA "; $image = imagecreatefromjpeg("frontrange.jpeg"); $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 = 70; $xt = round($cos*($x) - $sin*($y)); $yt = round($sin*($x) + $cos*($y)); imagettftext($image,20,180-($a),110+$xt,100+$yt,$red,"Fonts/Palatino",$text[$i]); } header("Content-type: image/jpeg"); imagejpeg($image,"",100); imagedestroy($image); ?> Link to comment https://forums.phpfreaks.com/topic/93815-trying-to-arc-text-on-an-image-layer-gd-liibrary/#findComment-481005 Share on other sites More sharing options...
Barand Posted March 1, 2008 Share Posted March 1, 2008 You can get rid of the saw-tooth effect on the character baselines by getting the angle at the midpoint of the characters' baselines rather than at the bottom left. Link to comment https://forums.phpfreaks.com/topic/93815-trying-to-arc-text-on-an-image-layer-gd-liibrary/#findComment-481069 Share on other sites More sharing options...
bobinindia Posted March 12, 2008 Author Share Posted March 12, 2008 Hi Barand, How do I get the angle at the midpoint of the characters baselines as you suggested? imagettftext() by default sets the angle from the bottom left. Is there a way around this? Link to comment https://forums.phpfreaks.com/topic/93815-trying-to-arc-text-on-an-image-layer-gd-liibrary/#findComment-490707 Share on other sites More sharing options...
Barand Posted March 12, 2008 Share Posted March 12, 2008 My code, that I pointed you towards earlier in this thread, does exactly that. Link to comment https://forums.phpfreaks.com/topic/93815-trying-to-arc-text-on-an-image-layer-gd-liibrary/#findComment-490719 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.