Link to home
Start Free TrialLog in
Avatar of basara55
basara55

asked on

Curve Text Dynamicaly

Can somone tell me how to curve text dynamically either using imagemagic or GD  in PHP?
Is it possible. And if not, is there some other tools that will allow me to do that dyamically in php?

Thanks
Avatar of rama_krishna580
rama_krishna580
Flag of United States of America image

Avatar of basara55
basara55

ASKER

But is it possible to do it in ImageMagik ? and how ?
Thats is close but does not curve the text nicely.  What i need is more like curving the text along the path , For example to curve the text in the shape of a circle.

Which means that each of the letters of the text have to rotate at the matching angle.

Anyone knows how to do this ?
Why you need curve.You can take any ttf font. And use it.
Copy yourfont.ttf file to server to same folder with your acript and write these to file:

<?php
  header("Content-type: image/jpeg");
  $im = imagecreate(400,30);
  $white = imagecolorallocate($im, 255,255,255);
  $black = imagecolorallocate($im, 0,0,0);
 
  // Replace path by your own font path
  imagettftext($im, 20, 0, 10, 20, $black, "yourfont.ttf",
  "Testing... Omega: &amp;#937;");
  imagejpeg($im);
  imagedestroy($im);
?>
Once again I need a script that will "Bend" or " Curve" or "arc" the text in either GD or Imagemagic.

I know how to write the text in imagemagic and gd , But how do you curve it.

I begining to think that only solution is to write my own function that will use some major Math Trigonometry.
Avatar of Marcus Bointon
I get where you're coming from. Like text on a path in Illustrator/Photoshop. The title of the feature in there is how it works too. Here's an example that uses SVG:

http://www.4guysfromrolla.com/demos/svgRender.asp

you could use this and render it server-side somehow in order to give an image usable in GD etc.

Otherwise I think you will need to do the math, as you say. You can place rotated characters in GD (jpGraph does it nicely, with anti-aliasing too), so the "difficult" part is done! You need to define a path, work out the path gradient at a given point, place the center of the char's baseline on it, rotated to match the path angle. You will also need to adjust char spacing for it to look right. I've found this example, which is in Java, but covers the kind of stuff you might need, includes text on curves, and looks quite cool:

http://www.glyphic.com/transform/

You might also find some of the links here useful:

http://www.programming-x.com/programming/curve.html

Sorry I don't have a quick answer (I don't think there is one), but I hope this helps.
thanks for your links i will go thru them , How do you save a svg to fiel on server on php ?
That's what I meant about the "somehow"! You need a server-side SVG renderer. Not sure if one exists specifically - there are probably some Java applets for rendering SVG, and they could probably be run server-side.
I'd love to have a server-side HTML renderer for soem things I do, but I've never seen one of those done either. Would be great to have somethign like Gecko, AppleWebKit (Safari) or IE as a PHP extension...
Thanks for your input , i'll wait few more days to see if anyone else has any other ideas or solutions .. and then i will award the points

ASKER CERTIFIED SOLUTION
Avatar of petoskey-001
petoskey-001

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great work petoeskey , Thats exactly what I needed.