|
|
|
|
![]() ![]() |
Feb 22 2006, 02:12 PM
Post
#1
|
|
|
Desperately seeking "any key" to continue... ![]() Group: Admin Posts: 3,434 Joined: 23-April 05 From: Trap17 storage box Member No.: 6,042 |
In search of dynamically changing quote, saying or all other types of text on an image I came across a code that I have modified to fit my initial usage. This procedure requires two files and short knowledge of PHP. If you are familiar with Trap17's sig rotation code you will understand this procedure very fast.
CODE <?php header("Content-type: image/png"); $image = imagecreatefrompng("../images/sotw_background.png"); //imagecolorallocate($image, R, G, B) in HEX values $font_black = imagecolorallocate($image, 2, 1, 8); $font_blue = imagecolorallocate($image, 25, 0, 255); $List = "name.txt"; $string = trim(file_get_contents($List));; //($image, fontsize, rightindent, downindent, data, txtcolour) imagestring($image, 3, 12, 3, "T17", $font_blue); imagestring($image, 1, 86, 6, "SOTW", $font_black); imagestring($image, 1, 110, 6, $string, $font_black); imagepng($image); imagedestroy($image); ?> Code 2 CODE WINNER - USERNAME For a working demo please refer to #23, #24 and #25 here http://www.trap17.com/forums/index.php?s=&...ndpost&p=222107 Let's break it down. As you can see in Code 1 CODE header("Content-type: image/png"); that HEADER calls for PNG as image type. This is crucial since only PNG images can handle dynamically applied text. CODE $image = imagecreatefrompng("../images/sotw_background.png"); states the location of the background image you are going to use. It looks like this ![]() CODE //imagecolorallocate($image, R, G, B) in HEX values as the remark that I made, the value of color in HEX will determine the text color you choose. I made two to make it as a comparison.$font_black = imagecolorallocate($image, 2, 1, 8); $font_blue = imagecolorallocate($image, 25, 0, 255); CODE $List = "name.txt"; This assigns a SINGLE line characters from file named name.txt. And then assigns to variable name STRING from the opened text file. If you don't want to use external file, you can simply set$string = trim(file_get_contents($List));; CODE $string = "your text 1"; etc. You can even do a random text where$string = "your text 2"; CODE $select = rand(1,7); if($select==1)$string = "text 1"; if($select==2)$string = "text 2"; if($select==3)$string = "text 3"; if($select==4)$string = "text 4"; if($select==5)$string = "text 5"; if($select==6)$string = "text 6"; if($select==7)$string = "text 7"; CODE //($image, fontsize, rightindent, downindent, data, txtcolour) This is where the magic happens. As you can see the position of the text is determined by second two numbers. The first number determines the font size. Instead of preset characters, i.e. T17 and SOTW, you can have $string1, $string2 etc.imagestring($image, 3, 12, 3, "T17", $font_blue); imagestring($image, 1, 86, 6, "SOTW", $font_black); imagestring($image, 1, 110, 6, $string, $font_black); The rest is needed to close up the PNG image and safely project reconstructed new image onto the browser. About the sig rotator reference: By renaming dynamic_sig.php to index.php and placing it under a directory called filename.png (yes directory with extension), you can use your newly created dynamic image in the forum CODE [img]http://source_site/filename.png[/img] This will display the dynamic image as though it's been there all along.One key note is that text is only written within the boundary of an image. So if you are looking for larger image simply make your picture larger in dimension. You can have multiple rows and variable font sizes. |
|
|
|
Feb 26 2006, 10:19 AM
Post
#2
|
|
|
[::Boy Wonder::] ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 2,098 Joined: 5-April 05 From: Costa Mesa, CA Member No.: 5,294 ![]() |
Great stuff Buffalo, and thanks for the help.
|
|
|
|
Jul 8 2006, 03:40 AM
Post
#3
|
|
|
Newbie [Level 2] ![]() ![]() Group: Members Posts: 30 Joined: 8-July 06 Member No.: 26,279 |
Yeah, it's very useful.
|
|
|
|
Jul 8 2006, 05:01 AM
Post
#4
|
|
|
Premium Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 162 Joined: 10-May 06 Member No.: 23,375 |
Hay i have a site dedicated towards this thing.
I made this sig generator and people can use it as well. Just register fill in the text and you are done. here is the link: www.esigs.be My sig is also using that. |
|
|
|
Jul 9 2006, 07:08 PM
Post
#5
|
|
|
Newbie [Level 2] ![]() ![]() Group: Members Posts: 33 Joined: 9-July 06 From: Belgium Member No.: 26,367 |
this is a great code, i've been looking for something like this everywere. tyvm
|
|
|
|
Jul 11 2006, 01:37 PM
Post
#6
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 357 Joined: 8-April 06 Member No.: 21,487 |
thanks dear BuffaloHELP
i want write sig maker ( random text , visit ip address and more ) how can i do that ? This is my questions for example do you have GD image soruce or tutorials ? i must user GD image ? thanks |
|
|
|
Nov 20 2006, 11:04 PM
Post
#7
|
|
|
Newbie [Level 2] ![]() ![]() Group: Members Posts: 25 Joined: 20-November 06 Member No.: 33,763 |
cool THX ^^
|
|
|
|
Apr 7 2007, 02:38 AM
Post
#8
|
|
|
Newbie ![]() Group: Members Posts: 1 Joined: 7-April 07 Member No.: 41,197 |
Great script, but for some reason when I upload it to my ftp and link it to forums it shows up as the dreaded red x. Do you have any ideas why this may be? I can send you my edited PHP file and everything if you need, I just really wanna get this thing working.
EDIT: I apologize, but I already fixed the problem. Thanks again for the script. This post has been edited by sendot: Apr 7 2007, 06:20 PM |
|
|
|
Apr 9 2007, 09:55 PM
Post
#9
|
|
|
Super Member ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Group: Members Posts: 292 Joined: 27-January 07 From: Winter is cold here. Member No.: 37,984 ![]() |
Wow, I was looking all over for a code like this one! I downloaded one once, but it included over 100 php files. which would take 2 hours to download and upload. Now I found a code that has two files and takes up little space!
|