LiveWire Peer Support Network

Printable Version of Topic "PHP/Dynamic Images?"

- LiveWire Teen Forums & College Forums (http://www.golivewire.com)
-- (http://www.golivewire.com/forums/support-technical.html)
--- Digital Arts & Music Technology (http://www.golivewire.com/forums/forum-205-s-0.html)
---- PHP/Dynamic Images? (http://www.golivewire.com/forums/peer-oeynpn-support-a.html)


-- Posted by ranman at 2:14 am on July 2, 2006

Does anyone have experience with creating a dynamic image? like one that displays your IP address and stuff...

These are my two terrible attemepts...

http://ranman.phpnet.us/sig1.php this one does not work but here is the code
Code:

header('Content-type: image/gif');
srand( microtime() * 100000 );
$num = rand( 1, 9 );

switch ( $num )
{
case 1 : $img_url="sig1.gif"; break;
case 2 : $img_url="sig2.gif"; break;
case 3 : $img_url="sig3.gif"; break;
case 4 : $img_url="sig4.gif"; break;
case 5 : $img_url="sig5.gif"; break;
case 6 : $img_url="sig6.gif"; break;
case 7 : $img_url="sig7.gif"; break;
case 8 : $img_url="sig8.gif"; break;
case 9 : $img_url="sig9.gif"; break;
}

$image = imagecreatefromgif("$im_url");

$black = imagecolorallocate($image, 0, 0, 0);
$white = imagecolorallocate($image, 255, 255, 255);

$ip = $_SERVER['REMOTE_ADDR']; // the ip address.

srand( microtime() * 100000 );
$num1 = rand( 1, 9 );

switch ( $num1 )
{
case 1 : $message="You wish you were as cool as me..."; break;
case 2 : $message="I eat noobs"; break;
case 3 : $message="The Ranman will own you"; break;
case 4 : $message="Ranman is currently... coding"; break;
case 5 : $message="Ranman is currently... eating"; break;
case 6 : $message="Ranman is currently... hacking"; break;
case 7 : $message="Ranman is currently... doing nothing"; break;
case 8 : $message="Hacked"; break;
case 9 : $message="Simplicity is best"; break;
}

imagestring($image, 5, 0, 0, "Your ip is $ip\n$message", $white); // this creates the text


imagegif($image);
imagedestroy($image);
?>

this one works but not well

http://ranman.phpnet.us/siggy.php
Code:

header('Content-type: image/gif');
$im_url = "sig3.gif"; // needs to end in .gif
$image = imagecreatefromgif("$im_url");

$black = imagecolorallocate($image, 0, 0, 0);
$white = imagecolorallocate($image, 255, 255, 255);

$ip = $_SERVER['REMOTE_ADDR']; // the ip address.

imagestring($image, 50, 50, 50, "Your ip is: $ip\nHaxx3d", $white); // this creates the text

imagegif($image);
imagedestroy($image);
?>


If this is in the wrong place could the appropriate authorities please move the post to the correct place?


www.golivewire.com