PhaZZed Posted November 28, 2007 Share Posted November 28, 2007 Greetings, I am curious about text to image encoding - I have had a look at phpclasses.org and have managed to download a library and convert some text to an image in png format - this is all working, but what I would really like to do is attempt to code one of these 'glitter text' things. In other words, the user would enter in their name and it would display their name in 'funky colourful' text. I've seen it done all over myspace and facebook, and just wonder how this works or if anyone has some sample code. There is a much bigger picture to this, I don't want to create a silly kids text converter, but I need the understanding before I can evolve. Any help will be appreciated. Thank-you! Quote Link to comment Share on other sites More sharing options...
PhaZZed Posted November 28, 2007 Author Share Posted November 28, 2007 ^bump Quote Link to comment Share on other sites More sharing options...
helraizer Posted November 28, 2007 Share Posted November 28, 2007 you'd want, somewhere along the lines of: <? $font = "funky_colourful.ttf"; //assuming it's in the same directory. If you want to give the user a choice of fonts, I'll tell you how to do that seperately if you so request. $red = ImageColorAllocate($image, 255, 0, 0); // Red $user = $_POST['username']; $text = $_POST['usertext']; // The text that'll be on the image //$image = ImageCreate(100,80); $image = ImageCreateFromPng("filename.png"); // Assuming you want to add the text to a pre-designed background, or whatever. $blue = ImageColorAllocate($image, 200, 200, 255); // prepare some blueness ImageFill($image, 0, 0, $blue); // fill the canvas imagettftext($image,10,0,10,10,$color,$font,$text); // header("Content-Type: image/png"); // tell the browser what we're gonna give it ImagePng($image); // paint the image in browser ImagePng($image, $user.".png"); //export as png file ImageDestroy($image); // clean up resources ?> Sam Quote Link to comment Share on other sites More sharing options...
PhaZZed Posted November 28, 2007 Author Share Posted November 28, 2007 That's fantastic helrazor!!! I got it running with a different font, and changing background colours, etc. I'm pretty well rehearsed in PHP so I can go wild from here! Just need to find out what each function does, so I can change the font size. I can write the code to change fonts, etc. that's easy Thanks a million and one! Quote Link to comment Share on other sites More sharing options...
helraizer Posted November 28, 2007 Share Posted November 28, 2007 Glad you got it working. Don't hesitate to ask if anything goes wrong. Sam Quote Link to comment Share on other sites More sharing options...
PhaZZed Posted November 28, 2007 Author Share Posted November 28, 2007 I actually dropped you an email.. Hey bud, Thanks a million for the help with the text to image on phpfreaks forums. I looked high and low for something like that, big up! http://www.sparklee.com/ That is an example of what I would like to acheive, I've managed to solve the font sizes and positioning, it's not the filling that might be tricky.. 1. create coloured background full of stars 2. print font on top 3. switch layers almost like that i suppose... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.