php created images
- Started
- Last post
- 11 Responses
- ldww
anyone ever used php to create images of text? wondering how well it renders the text.
- rabattski0
i don't think you can do that with php by default. there are server side apps which you can control thru php but not with php itself. or am i missing something?
- nospacebar0
You can do it with GD, which comes with PHP. Look up 'ImageTTFBBox' and 'ImageTTFText' at www.php.net
Email me if you have any questions after looking at that documentation.
- nospacebar0
Here's a little example I whipped up for ya. It renders the text anti-aliased if that was your question.
Example:
http://www.meandmybadself.com/la…And the source is here:
http://www.meandmybadself.com/la…
- ldww0
oh wow! that rocks, thanks.
- randomBboy0
nospacebar:
Is it possible to rotate the text?was looking for a way to just rotate text in a browser but it seems only IE has the ability, this may be a work around to solve my problem
- nospacebar0
Yep!
I'll append to the example listed above.
- ldww0
i can not seem to get it to work, i put arial in the same directory as the php and added it to the drop down, but it says :
Warning: imagettftext(): Could not find/open font in /usr/www/users/ldww/textimg/imde... on line 10
‰PNG IHDR^F¾nPLTEÿÿÿUÂÓ~IDATxœ... õOmo N³ZlÁIEND®B`‚
- nospacebar0
You need to make sure that .ttf is lowercase, and do not refer to it as 'Arial.ttf', but simply 'Arial'.
Also, on some PHP setups, it looks for the font in /usr/share/fonts/truetype/
- nospacebar0
I updated the example and the source code to edit the rotation via the HTML form.
Now, LUNCH!
- rabattski0
but GD needs to be installed on the server right?
- nospacebar0
Correct. GD is an extension library for PHP.