Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Posted on
- Finding A Word's Length In Pixels
August 23, 2007, 1:51 pm
rate this thread
Using the GD library, I want to print a word or string as an image,
but with some constant amount of padding around it. The text is not
known beforehand. In other words, something like
| flan |
I'm very new to GD, but offhand the only solution that comes to mind
is to create a very long general-purpose image, print the text at (x1,
0), measure the word there, destroy the image, then create a second
image with dimensions calculated from before. That seems rather
sloppy. Is there a better alternative?
Re: Finding A Word's Length In Pixels
Wrong. Don't make rash assumptions about what the project
requirements should be when that project hasn't been described. A
need was posted, so the proper response is to address that need
rather than question it. There are plenty of reasons why someone
may want to render text as graphics:
* Graphical display of data requires text on the graph axes and
legend, and that makes most sense as part of the graphic.
* CAPTCHA requires the use of text in graphics.
* Using some text as graphics is a good way to shield content from
spiders and crawlers.
* Clickable buttons containing text descriptions.