|
||||||
| PHP Tutorials PHP Tutorials |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
First some variables to define how the function will work.
$theText is the text that we want to have in the image. The other variables should also be pretty easy to understand... I defined them in variables so you easily can change them to try different things. The first thing which is a little bit tricky is the "imageTTFBBox"-function. Not really self explaining hehe :-) What it does is depending on the parameters it gives back the size of the bounding box needed for this text, in pixels. You get an array with this information: 0 lower left corner, X position 1 lower left corner, Y position 2 lower right corner, X position 3 lower right corner, Y position 4 upper right corner, X position 5 upper right corner, Y position 6 upper left corner, X position 7 upper left corner, Y position The next step is to create the image (empty but with correct size to fit the text) with this function: imageCreateTrueColor(x, y) You give the function the width in x and y, and you get the values you see in the function call. imageSaveAlpha sets the mode to save all alpha channel information, which is needed to make a png file transparent. ImageAlphaBlending sets the blending mode off, which meens "simply" that the alpha information is preserved. (not that important, just set it to false hehe) imagecolorallocatealpha allocates a color for an image, and sets how transparent it should be. 0 is NO transparency and 127 is fully transparent. 127 is prefect for us, but you can always mess around with the numbers to se what happens :-) This color variable is used for filling the "real" image with transparent color. The last part is pretty straight forward. Get textColor, and write the text in the image. After that we just save it with the name textImage.png. OBS, the web server needs write permissions to this catalog. So if you are going to use this in a live application/site, you should put the images in a separate directory and change permissions on that. PHP Code:
Ref: Front Page | Pixel Groovy Last edited by John; 01-06-2007 at 11:25 PM. Reason: Please use the [php], [code], and [html] functions when appropriate. Makes it easier to read. :) |
| Sponsored Links |
|
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Grab Text within IE | xxarmoxx | Visual Basic Programming | 1 | 04-06-2007 08:42 AM |
| HTML Basic Formatting | clookid | Tutorials | 14 | 03-06-2007 03:10 PM |
| Glass text - Photoshop | ahsan16 | Photoshop Tutorials | 3 | 01-11-2007 10:35 PM |
| Make Text Fade In | Chan | Website Design | 2 | 01-10-2007 12:46 PM |
Goal: 100,000 Posts
Complete: 67%