note 38744 added to ref.image
| From: | spannme at hotmail dot com dot NOSPAM | Date: | Mon, 05 Jan 2004 17:57:47 +0000 |
| Subject: | note 38744 added to ref.image | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-62962@lists.php.net to get a copy of this message | ||
A nice winamp plugin, that puts the currently playing songtitle into a pic,
so that it can be used as a signature in forums, brought me on this idea,
after i wanted to create a random signature when winamp is off.
Author: http://www.matttt.nl/
Winamp Plugin: http://www.winamp.com/plugins/details.php?id=133663
the following part doesn't require the plugin,
just a 'sig.txt' with the random signatures you want to be displayed
<?php
header ("Content-type: image/png");
/* default signature, if you want to use it.
* i use it, to be displayed more often than
* the random ones (change below),
* or if something went wrong with the file */
$standartsig = 'My Standart Sig';
//file with your random sigs, one per line
$sigfile = 'sig.txt';
//display standart sig? - change at will
if (rand(0,10) <= 4) {
$tmp = $standartsig;}
else {
//get a random line, to use as signature
if (file_exists($sigfile)) {
$array = file($sigfile);
$anzahl = count($array) - 1;
$tmp = trim($array[rand(0,$anzahl)]);
if (strlen($tmp) <= 1) {$tmp = $standartsig;} //line not empty?
} else {$tmp = $standartsig;}
}
/* create Picture -- or use echo($tmp);
* but don't forget to change or remove the "header()" then */
$im = imagecreate (6*strlen($tmp),14);
$background_color = imagecolorallocate ($im, 255, 255, 255);
$background_color = imagecolortransparent($im,$background_color);
$text_color = imagecolorallocate ($im, 0, 0, 0);
imagestring ($im, 2, 0, 0, $tmp, $text_color);
imagepng ($im);
?>
if anyone has a better idea of how to create a transparent background,
feel free to email me (just remove ".NOSPAM")
----
Manual Page -- http://www.php.net/manual/en/ref.image.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+38744
Delete -- http://master.php.net/manage/user-notes.php?action=delete+38744&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+38744&report=yes
Search -- http://master.php.net/manage/user-notes.php