- Code 1: dynamic_sig.php (you can rename this to index.php and you'll see at the end why)
- Code 2: a simple text file named anything (I will call it name.txt)
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);
?>
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
$font_black = imagecolorallocate($image, 2, 1, 8);
$font_blue = imagecolorallocate($image, 25, 0, 255);
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";
$string = trim(file_get_contents($List));;
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";
$string = "your text 2";
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";
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)
imagestring($image, 3, 12, 3, "T17", $font_blue);
imagestring($image, 1, 86, 6, "SOTW", $font_black);
imagestring($image, 1, 110, 6, $string, $font_black);
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.


