KiaraRytzar Posted January 6, 2009 Share Posted January 6, 2009 -- Note - I am very new to php so if you start mentioning things like arrays and loops etc. I probably won't know what you're talking about, so keep things simple, okay? XD -- Well, there are a few things I need to get codes for. I know html, and have my own site, so I'm looking to add some things that only php can do. Because there are so many things I need, I will ask one question at a time, and when that is answered, I will ask my next question ~*~ 1st Question~ What I want to do is get a code that will add writing to an image. You probably don't know what I mean by that, so I will try to explain... Say you have a page on your site called "Adopts" or something. When you go to it, there will be a small picture of a cat (yes, a cat ). Then there is a link or a button beside it that says "Adopt this cat". You click on it and it takes you to another page. Then it says "what is your name?" and it has a small text box for you to write your name. So you write in your name (example "Hazel"). Then you click "adopt" again and it takes you to another page with codes to put your "pet" on a forum or website with links back etc. But now, instead of it just being a simple picture, it has written along the bottom line "Hazel's Pet". Also, another thing (which is very similar)... The code before the name feature is something like (in html) *image and link codes* <br> <b>Your name~</b>type your name here ..so that whoever 'adopted' the cat will be able to put that code on a html site and it will display the cat image with their name below it, but they will have to write in their name manually or else it'll still say "type your name here". Then, with this 'new feature' I want it to be able to come up with (if your name is still Hazel)... *image and link codes* <br> <b>Your name~</b>Hazel ...so that it automatically puts the name you typed into the code. So I would like to know (for now) how to get the writing that someone has just written in a text box (or whatever) to appear on the image they "adopted" followed by 's Pet and for it to appear after "Your name~" in the code. I hope this makes sense, and that someone will know the answer =3 ~Kiara Quote Link to comment https://forums.phpfreaks.com/topic/139675-a-few-things-i-need-answered/ Share on other sites More sharing options...
cwarn23 Posted January 6, 2009 Share Posted January 6, 2009 I would suggest using the gd library/commands and if you would prefer a basic function then try the imagestring() function. And so first you setup a blank php file which will from a html point of view be what the browser sees as the picture file. So when setting up this new php file, first you need to import the current image, then place ontop of the image the text with the imagestring() function. Below is a quick sketch I did of the code: <? $text='Hazel'; // text to display in white (size at top left corner. $imgname='imgtest.jpg'; //set the to jpeg filename inside same directory $im = @imagecreatefromjpeg($imgname); $color = imagecolorallocate($im, 255, 255, 255); //set this to rgb color imagestring($im, 8, 5, 5, $text, $color); imagejpeg($im); imagedestroy($im); ?> If you wish to style up the text other than just the color then you may want to use an alternative function to imagestring() but other than that those are the basics. Documentation Links: http://au2.php.net/manual/en/function.imagestring.php http://au2.php.net/manual/en/function.imagecreatefromjpeg.php enjoy. Quote Link to comment https://forums.phpfreaks.com/topic/139675-a-few-things-i-need-answered/#findComment-730798 Share on other sites More sharing options...
KiaraRytzar Posted January 6, 2009 Author Share Posted January 6, 2009 I would suggest using the gd library/commands and if you would prefer a basic function then try the imagestring() function. And so first you setup a blank php file which will from a html point of view be what the browser sees as the picture file. So when setting up this new php file, first you need to import the current image, then place ontop of the image the text with the imagestring() function. Below is a quick sketch I did of the code: <? $text='Hazel'; // text to display in white (size at top left corner. $imgname='imgtest.jpg'; //set the to jpeg filename inside same directory $im = @imagecreatefromjpeg($imgname); $color = imagecolorallocate($im, 255, 255, 255); //set this to rgb color imagestring($im, 8, 5, 5, $text, $color); imagejpeg($im); imagedestroy($im); ?> If you wish to style up the text other than just the color then you may want to use an alternative function to imagestring() but other than that those are the basics. Documentation Links: http://au2.php.net/manual/en/function.imagestring.php http://au2.php.net/manual/en/function.imagecreatefromjpeg.php enjoy. I tried that out, but there are still a few problems... The images I use are .png, not .jpeg When the image comes up, the background becomes black. Is there any way for it to stay the same instead of changing the background? The writing should be at the bottom left corner, not the top Not everyone's name is Hazel. I need to find a code (or codes) that will print whatever the "adopter" wrote in the textbox. More than a few problems, I guess XD Quote Link to comment https://forums.phpfreaks.com/topic/139675-a-few-things-i-need-answered/#findComment-730843 Share on other sites More sharing options...
KiaraRytzar Posted January 7, 2009 Author Share Posted January 7, 2009 Anyone? Quote Link to comment https://forums.phpfreaks.com/topic/139675-a-few-things-i-need-answered/#findComment-731478 Share on other sites More sharing options...
JonnoTheDev Posted January 7, 2009 Share Posted January 7, 2009 The images I use are .png, not .jpeg When the image comes up, the background becomes black. Is there any way for it to stay the same instead of changing the background? The writing should be at the bottom left corner, not the top Not everyone's name is Hazel. I need to find a code (or codes) that will print whatever the "adopter" wrote in the textbox. Learn PHP's GD library functions. There are PNG functions just as JPEG functions. Learn the function parameters to move the text to the desired location. Learn how to create an HTML form that will post to the PHP file and use the input in a variable to display on the graphic. Don't try to get people here to do the whole job for you. Quote Link to comment https://forums.phpfreaks.com/topic/139675-a-few-things-i-need-answered/#findComment-731649 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.